Fix flaky migration tests (mihonapp/mihon#2663)
(cherry picked from commit 506d51a007e730594e4e5f05f00b4f94c4f24e05)
This commit is contained in:
parent
1a40ab5114
commit
f225e611c6
1 changed files with 7 additions and 5 deletions
|
|
@ -1,5 +1,6 @@
|
|||
package mihon.core.migration
|
||||
|
||||
import io.kotest.assertions.nondeterministic.eventually
|
||||
import io.mockk.slot
|
||||
import io.mockk.spyk
|
||||
import io.mockk.verify
|
||||
|
|
@ -18,6 +19,7 @@ import org.junit.jupiter.api.Assertions.assertInstanceOf
|
|||
import org.junit.jupiter.api.BeforeAll
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.Test
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
|
||||
class MigratorTest {
|
||||
|
||||
|
|
@ -27,7 +29,7 @@ class MigratorTest {
|
|||
lateinit var migrationStrategyFactory: MigrationStrategyFactory
|
||||
|
||||
@BeforeEach
|
||||
fun initilize() {
|
||||
fun initialize() {
|
||||
migrationContext = MigrationContext(false)
|
||||
migrationJobFactory = spyk(MigrationJobFactory(migrationContext, CoroutineScope(Dispatchers.Main + Job())))
|
||||
migrationCompletedListener = spyk<MigrationCompletedListener>(block = {})
|
||||
|
|
@ -47,7 +49,7 @@ class MigratorTest {
|
|||
@Suppress("DeferredResultUnused")
|
||||
verify { migrationJobFactory.create(capture(migrations)) }
|
||||
assertEquals(1, migrations.captured.size)
|
||||
verify { migrationCompletedListener() }
|
||||
eventually(2.seconds) { verify { migrationCompletedListener() } }
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -91,7 +93,7 @@ class MigratorTest {
|
|||
@Suppress("DeferredResultUnused")
|
||||
verify { migrationJobFactory.create(capture(migrations)) }
|
||||
assertEquals(2, migrations.captured.size)
|
||||
verify { migrationCompletedListener() }
|
||||
eventually(2.seconds) { verify { migrationCompletedListener() } }
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -120,7 +122,7 @@ class MigratorTest {
|
|||
@Suppress("DeferredResultUnused")
|
||||
verify { migrationJobFactory.create(capture(migrations)) }
|
||||
assertEquals(10, migrations.captured.size)
|
||||
verify { migrationCompletedListener() }
|
||||
eventually(2.seconds) { verify { migrationCompletedListener() } }
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -142,7 +144,7 @@ class MigratorTest {
|
|||
@Suppress("DeferredResultUnused")
|
||||
verify { migrationJobFactory.create(capture(migrations)) }
|
||||
assertEquals(2, migrations.captured.size)
|
||||
verify { migrationCompletedListener() }
|
||||
eventually(2.seconds) { verify { migrationCompletedListener() } }
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
|
|
|||
Loading…
Reference in a new issue