Created
May 14, 2018 20:13
-
-
Save xcesco/60d73015d99e53b9c18779cafd51612e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void testMigration() throws Exception { | |
// Context of the app under test. | |
Context testContext = InstrumentationRegistry.getContext(); | |
Context context = InstrumentationRegistry.getTargetContext(); | |
KriptonLibrary.init(context); | |
InputStream schema1 = testContext.getAssets().open("xeno_schema_1.sql"); | |
InputStream schema2 = testContext.getAssets().open("xeno_schema_2.sql"); | |
InputStream finalSchema1 = testContext.getAssets().open("xeno_schema_1.sql"); | |
InputStream finalSchema2 = testContext.getAssets().open("xeno_schema_2.sql"); | |
SQLiteTestDatabase.clearDatabase(context); | |
SQLiteTestDatabase database = SQLiteTestDatabase.builder(1, schema1) | |
.addPopulator(datasource -> XenoApplication.fillCountryCodes(context)) | |
.addVersionUpdateTask(2, (datasource, previousVersion, currentVersion) -> XenoApplication.migrationVersion2(context, datasource)) | |
.build(); | |
database.updateAndVerify(1, finalSchema1); | |
database.updateAndVerify(2, finalSchema2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment