migration : fix presenter test for fresh/old install
This commit is contained in:
parent
ddc15bd81a
commit
6b1f3b9e4a
1 changed files with 6 additions and 6 deletions
|
|
@ -27,12 +27,9 @@ class MigrationPresenterTest {
|
||||||
val warmUpRule = WarmUpRule()
|
val warmUpRule = WarmUpRule()
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `present - no migration should occurs on fresh installation, and last version should be stored`() = runTest {
|
fun `present - run all migrations on fresh installation, and last version should be stored`() = runTest {
|
||||||
val migrations = (1..10).map { order ->
|
val migrations = (1..10).map { order ->
|
||||||
FakeAppMigration(
|
FakeAppMigration(order = order)
|
||||||
order = order,
|
|
||||||
migrateLambda = LambdaNoParamRecorder(ensureNeverCalled = true) { },
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
val store = InMemoryMigrationStore(initialApplicationMigrationVersion = -1)
|
val store = InMemoryMigrationStore(initialApplicationMigrationVersion = -1)
|
||||||
val presenter = createPresenter(
|
val presenter = createPresenter(
|
||||||
|
|
@ -44,12 +41,15 @@ class MigrationPresenterTest {
|
||||||
}.test {
|
}.test {
|
||||||
val initialState = awaitItem()
|
val initialState = awaitItem()
|
||||||
assertThat(initialState.migrationAction).isEqualTo(AsyncData.Uninitialized)
|
assertThat(initialState.migrationAction).isEqualTo(AsyncData.Uninitialized)
|
||||||
skipItems(1)
|
skipItems(migrations.size)
|
||||||
awaitItem().also { state ->
|
awaitItem().also { state ->
|
||||||
assertThat(state.migrationAction).isEqualTo(AsyncData.Success(Unit))
|
assertThat(state.migrationAction).isEqualTo(AsyncData.Success(Unit))
|
||||||
}
|
}
|
||||||
assertThat(store.applicationMigrationVersion().first()).isEqualTo(migrations.maxOf { it.order })
|
assertThat(store.applicationMigrationVersion().first()).isEqualTo(migrations.maxOf { it.order })
|
||||||
}
|
}
|
||||||
|
for (migration in migrations) {
|
||||||
|
migration.migrateLambda.assertions().isCalledOnce()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue