From 17b5ff3d3ca5f0824454c77cb1ae8373c7b7f445 Mon Sep 17 00:00:00 2001 From: Sunny Chung Date: Sat, 9 Nov 2024 01:14:19 +0800 Subject: [PATCH] fix ChunkedLatestFlowTest was failing in some runner --- .../test/util/ChunkedLatestFlowTest.kt | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/jvmTest/kotlin/com/sunnychung/application/multiplatform/hellohttp/test/util/ChunkedLatestFlowTest.kt b/src/jvmTest/kotlin/com/sunnychung/application/multiplatform/hellohttp/test/util/ChunkedLatestFlowTest.kt index 7d075d93..186158f8 100644 --- a/src/jvmTest/kotlin/com/sunnychung/application/multiplatform/hellohttp/test/util/ChunkedLatestFlowTest.kt +++ b/src/jvmTest/kotlin/com/sunnychung/application/multiplatform/hellohttp/test/util/ChunkedLatestFlowTest.kt @@ -22,12 +22,15 @@ class ChunkedLatestFlowTest { coroutineScope { flow { + val startTime = System.currentTimeMillis() (0..10).forEach { emit(it) - delay(1450) + val currTime = System.currentTimeMillis() + println("t=${currTime - startTime}: $it") + delay((it + 1) * 145 - (currTime - startTime)) } } - .chunkedLatest(5000.milliseconds()) + .chunkedLatest(500.milliseconds()) .onEach { results += it } .launchIn(this) } @@ -43,14 +46,17 @@ class ChunkedLatestFlowTest { coroutineScope { flow { + val startTime = System.currentTimeMillis() (0..10).forEach { emit(it) - delay(1450) + val currTime = System.currentTimeMillis() + println("t=${currTime - startTime}: $it") + delay((it + 1) * 145 - (currTime - startTime)) } emit(11) emit(12) } - .chunkedLatest(5000.milliseconds()) + .chunkedLatest(500.milliseconds()) .onEach { results += it } .launchIn(this) } @@ -66,12 +72,15 @@ class ChunkedLatestFlowTest { coroutineScope { flow { + val startTime = System.currentTimeMillis() (0..12).forEach { emit(it) - delay(1450) + val currTime = System.currentTimeMillis() + println("t=${currTime - startTime}: $it") + delay((it + 1) * 145 - (currTime - startTime)) } } - .chunkedLatest(5000.milliseconds()) + .chunkedLatest(500.milliseconds()) .onEach { results += it } .launchIn(this) }