Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing migrations #1

Open
reixa00 opened this issue Aug 26, 2019 · 1 comment
Open

Testing migrations #1

reixa00 opened this issue Aug 26, 2019 · 1 comment

Comments

@reixa00
Copy link

reixa00 commented Aug 26, 2019

This should be more a question than an issue, don't know if theres a StackOverflow tag to ask them there, feel free to close if so.

At the moment I'm testing the migrations that I use like this:

@SmallTest
class MigrationTest {

    private val TEST_DB = "migration-test"

    @get:Rule
    var helper: MigrationTestHelper? = null

    init {
        helper = MigrationTestHelper(InstrumentationRegistry.getInstrumentation(),
                AnomalyDatabase::class.java.canonicalName, FrameworkSQLiteOpenHelperFactory())
    }

    @Test
    fun migrate57To58() {
        val db = helper?.createDatabase(TEST_DB, 57)
        db?.close()
        helper?.runMigrationsAndValidate(TEST_DB, 58, true, DBMigrations.MIGRATION_57_58)
    }
}

Is there a way to test the migrations created by the library? Maybe being created at compile time makes this task difficult.

Thanks in advance. I really think this could be a powerful tool.

@MatrixDev
Copy link
Owner

Hey axierjhtjz,

I'm glad that you found this library useful.

In the above sample you can just iterate over migrations and test each migration in a loop? It should be pretty easy as each migration object has versions of database to migrate to/from.

Best regards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants