Hi! I'm trying to test some IOs with delays, but g...
# arrow
k
Hi! I'm trying to test some IOs with delays, but get some
IllegalStateException: This job has not completed yet
. Here's a basic example, could you tell me what I'm doing wrong ? Thanks
Copy code
@Test
    fun test() = runBlockingTest {
        IO.effect { delay(10000) }.suspended()
    }
This works, but the test actually wait for the delay, how can I avoid it?
Copy code
@Test
    fun test() {
        IO.effect { delay(10000) }.unsafeRunSync()
        println("Done")
    }
p
why shouldn’t the test wait for the delay?
I’m not familiar with the implementation of
runBlockingTest
, it’s from kotlinx.coroutines who do their own thing
k
The example is pretty stupid, but in reality, I'm implementing some sort of retrying after a delay. But for my tests, the duration of the delay is not really something I absolutely need to test. I guess I could pass the delay as a parameter, but I've seen that
kotlinx-coroutines-test
gives some control over the clock, but I don't really know how to use it alongside IOs
p
Oh, there’s a scheduler that supports time dilation, right?
that should be compatible