Commit 4a3f8fd0 authored by MozLando's avatar MozLando
Browse files

Merge #5064



5064: Closes #5041: Fix migration post-processing to understand FxA migrations r=pocmo a=grigoryk

When FxA migration was added, I forgot to adjust "read and parse past migrations" code
to account for a new migration type. This patch fixes that problem, and adds tests that
would have cought it.
Co-authored-by: default avatarGrisha Kruglov <gkruglov@mozilla.com>
parents fd14fd29 f415ca3e
......@@ -57,6 +57,7 @@ internal class MigrationResultsStore(context: Context) : SharedPreferencesCache<
Migration.Bookmarks.javaClass.simpleName -> Migration.Bookmarks
Migration.OpenTabs.javaClass.simpleName -> Migration.OpenTabs
Migration.Gecko.javaClass.simpleName -> Migration.Gecko
Migration.FxA.javaClass.simpleName -> Migration.FxA
else -> throw IllegalStateException("Unrecognized migration type: $migrationName")
}
result[migration] = MigrationRun(version = migrationVersion, success = migrationSuccess)
......
......@@ -30,6 +30,7 @@ import java.lang.IllegalStateException
import kotlinx.coroutines.CompletableDeferred
import mozilla.components.service.fxa.sharing.ShareableAccount
import mozilla.components.support.test.argumentCaptor
import org.mockito.Mockito.reset
@RunWith(AndroidJUnit4::class)
class FennecMigratorTest {
......@@ -422,6 +423,13 @@ class FennecMigratorTest {
}
verifyZeroInteractions(accountManager)
// Does not run FxA migration again.
with(migrator.migrateAsync().await()) {
assertEquals(0, this.size)
}
verifyZeroInteractions(accountManager)
}
@Test
......@@ -441,6 +449,13 @@ class FennecMigratorTest {
}
verifyZeroInteractions(accountManager)
// Does not run FxA migration again.
with(migrator.migrateAsync().await()) {
assertEquals(0, this.size)
}
verifyZeroInteractions(accountManager)
}
@Test
......@@ -469,6 +484,14 @@ class FennecMigratorTest {
assertEquals("252fsvj8932vj32movj97325hjfksdhfjstrg23yurt267r23", captor.value.authInfo.kSync)
assertEquals("0b3ba79bfxdf32f3of32jowef7987f", captor.value.authInfo.kXCS)
assertEquals("fjsdkfksf3e8f32f23f832fwf32jf89o327u2843gj23", captor.value.authInfo.sessionToken)
// Does not run FxA migration again.
reset(accountManager)
with(migrator.migrateAsync().await()) {
assertEquals(0, this.size)
}
verifyZeroInteractions(accountManager)
}
@Test
......@@ -498,5 +521,13 @@ class FennecMigratorTest {
assertEquals("252bc4ccc3a239fsdfsdf32fg32wf3w4e3472d41d1a204890", captor.value.authInfo.kSync)
assertEquals("0b3ba79b18bd9fsdfsdf4g234adedd87", captor.value.authInfo.kXCS)
assertEquals("fsdfjsdffsdf342f23g3ogou97328uo23ij", captor.value.authInfo.sessionToken)
// Does not run FxA migration again.
reset(accountManager)
with(migrator.migrateAsync().await()) {
assertEquals(0, this.size)
}
verifyZeroInteractions(accountManager)
}
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment