saket
03/28/2023, 3:47 PM.sq
file and prefix them with test
hfhbd
03/28/2023, 4:36 PMtest-queries
, add the main database as dependency and depend on the test module in commonTest
.Trevor Stone
03/28/2023, 6:05 PMjw
03/28/2023, 6:06 PMMiky Ma
03/28/2023, 6:32 PMManuel Pérez Alcolea
03/29/2023, 6:15 AMJdbcSqliteDriver
val database: Database = ...
val queries: MyQueries = database.myQueries
// request for transaction in thread A
queries.insertPerson("Joseph")
// request for transaction in thread B
queries.insertPerson("Martina")
Philip Dukhov
03/29/2023, 1:15 PMleandro
03/29/2023, 1:27 PMPhilip Dukhov
03/29/2023, 1:39 PMjw
03/29/2023, 1:40 PMjw
03/29/2023, 1:41 PMjean
03/29/2023, 1:51 PM@Test
fun shouldTimeOut() = runTest {
suspend fun number(): Int {
delay(2000)
return 1
}
flow {
emit(0)
withTimeout(1000) {
emit(number())
}
}.test {
assertEquals(0, awaitItem())
assertTrue(awaitError() is TimeoutCancellationException)
}
}
I get No value produced in 1s
rather than a timeout exceptionStylianos Gakis
03/29/2023, 1:55 PMjw
03/29/2023, 1:55 PMBenoit Quenaudon
03/29/2023, 1:56 PMjw
03/29/2023, 1:56 PMjean
03/29/2023, 7:07 PMNo value produced in 3s
saket
03/29/2023, 7:11 PMrunTest
which skips delays so your delay(2000)
and withTimeout(1000)
should return immediatelyjw
03/29/2023, 7:12 PMjw
03/29/2023, 7:12 PMjean
03/29/2023, 7:22 PMsaket
03/29/2023, 7:23 PMReceiveChannel<T>.awaitEvent()
is receiving the TimeoutCancellationException
and it's incorrectly thinking the test actually timed outjw
03/29/2023, 7:23 PMjw
03/29/2023, 7:24 PMsaket
03/29/2023, 7:24 PMTurbineTimeoutCancellationException
already our custom timeout exception?jean
03/29/2023, 7:24 PMjean
03/29/2023, 7:32 PMadte
03/29/2023, 11:25 PMjw
03/29/2023, 11:40 PM