Jonathan
06/09/2025, 3:39 PMCLOVIS
06/10/2025, 9:34 AMJonathan
06/10/2025, 1:08 PMflow
collection) thats wrapped in a withTimeoutOrNull(…) {}
and I would like to test proper timeout logic but using delays to emit values into my flow above don’t seem to work. When testing, the timeout would expire even when the delay was below the delays used.Jonathan
06/10/2025, 1:09 PMadvanceTimeBy(...)
seemed to help a bit but my bigger issue is I’m not sure if that’s the proper solution or if I’m just changing my test slightly therefore making it no longer valid by don’t realize.CLOVIS
06/10/2025, 2:56 PMJonathan
06/10/2025, 2:57 PMflow {}
before I emitted an item.CLOVIS
06/10/2025, 2:59 PMrunTest {
val yourThingAsync = async {
// the thing you want to test, ensure there is an infinite delay within the withTimeoutOrNull {}
}
delay(5.minutes) // or however long the timeout should be
check(yourThingAsync.isComplete)
val yourThing = yourThingAsync.await()
check(yourThing.…)
}
CLOVIS
06/10/2025, 2:59 PMchristophsturm
06/17/2025, 10:03 AMCLOVIS
06/17/2025, 10:07 AMchristophsturm
06/17/2025, 11:45 AMCLOVIS
06/17/2025, 12:06 PMwithTimeout
is based on a TimeSource
, not a Clock
, but sure, that's still only half of the answer. How would you write it?