|
|
|
@ -3,11 +3,12 @@ package org.koitharu.kotatsu.core.db
|
|
|
|
import androidx.room.testing.MigrationTestHelper
|
|
|
|
import androidx.room.testing.MigrationTestHelper
|
|
|
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
|
|
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
|
|
|
import androidx.test.platform.app.InstrumentationRegistry
|
|
|
|
import androidx.test.platform.app.InstrumentationRegistry
|
|
|
|
import java.io.IOException
|
|
|
|
|
|
|
|
import org.junit.Rule
|
|
|
|
import org.junit.Rule
|
|
|
|
import org.junit.Test
|
|
|
|
import org.junit.Test
|
|
|
|
import org.junit.runner.RunWith
|
|
|
|
import org.junit.runner.RunWith
|
|
|
|
import org.koitharu.kotatsu.core.db.migrations.*
|
|
|
|
import org.koitharu.kotatsu.core.db.migrations.*
|
|
|
|
|
|
|
|
import java.io.IOException
|
|
|
|
|
|
|
|
import kotlin.test.assertEquals
|
|
|
|
|
|
|
|
|
|
|
|
@RunWith(AndroidJUnit4::class)
|
|
|
|
@RunWith(AndroidJUnit4::class)
|
|
|
|
class MangaDatabaseTest {
|
|
|
|
class MangaDatabaseTest {
|
|
|
|
@ -21,17 +22,15 @@ class MangaDatabaseTest {
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
@Throws(IOException::class)
|
|
|
|
@Throws(IOException::class)
|
|
|
|
fun migrateAll() {
|
|
|
|
fun migrateAll() {
|
|
|
|
helper.createDatabase(TEST_DB, 1).apply {
|
|
|
|
assertEquals(DATABASE_VERSION, migrations.last().endVersion)
|
|
|
|
// TODO execSQL("")
|
|
|
|
helper.createDatabase(TEST_DB, 1).close()
|
|
|
|
close()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for (migration in migrations) {
|
|
|
|
for (migration in migrations) {
|
|
|
|
helper.runMigrationsAndValidate(
|
|
|
|
helper.runMigrationsAndValidate(
|
|
|
|
TEST_DB,
|
|
|
|
TEST_DB,
|
|
|
|
migration.endVersion,
|
|
|
|
migration.endVersion,
|
|
|
|
true,
|
|
|
|
true,
|
|
|
|
migration
|
|
|
|
migration
|
|
|
|
)
|
|
|
|
).close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -50,6 +49,7 @@ class MangaDatabaseTest {
|
|
|
|
Migration8To9(),
|
|
|
|
Migration8To9(),
|
|
|
|
Migration9To10(),
|
|
|
|
Migration9To10(),
|
|
|
|
Migration10To11(),
|
|
|
|
Migration10To11(),
|
|
|
|
|
|
|
|
Migration11To12(),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|