Skip to content

Commit

Permalink
Get rid of real time in TimeoutTest
Browse files Browse the repository at this point in the history
* To avoid races on very slow Windows-virtualized TC agents
  • Loading branch information
qwwdfsad committed Oct 12, 2022
1 parent 298eb11 commit 1656a0d
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions kotlinx-coroutines-core/common/test/flow/operators/TimeoutTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class TimeoutTest : TestBase() {
}

@Test
fun testUpstreamTimeoutIsolatedContext() = runTest {
fun testUpstreamTimeoutIsolatedContext() = withVirtualTime {
val flow = flow {
assertEquals("upstream", NamedDispatchers.name())
expect(1)
Expand All @@ -169,7 +169,7 @@ class TimeoutTest : TestBase() {
}

@Test
fun testUpstreamTimeoutActionIsolatedContext() = runTest {
fun testUpstreamTimeoutActionIsolatedContext() = withVirtualTime {
val flow = flow {
assertEquals("upstream", NamedDispatchers.name())
expect(1)
Expand All @@ -187,21 +187,7 @@ class TimeoutTest : TestBase() {
}

@Test
fun testUpstreamNoTimeoutIsolatedContext() = runTest {
val flow = flow {
assertEquals("upstream", NamedDispatchers.name())
expect(1)
emit(1)
expect(2)
delay(10)
}.flowOn(NamedDispatchers("upstream")).timeout(100.milliseconds)

assertEquals(listOf(1), flow.toList())
finish(3)
}

@Test
fun testSharedFlowTimeout() = runTest {
fun testSharedFlowTimeout() = withVirtualTime {
// Workaround for JS legacy bug
try {
MutableSharedFlow<Int>().asSharedFlow().timeout(100.milliseconds).collect()
Expand Down

0 comments on commit 1656a0d

Please sign in to comment.