Fix database test

pull/203/head
Koitharu 4 years ago
parent f0ee64bafa
commit aa5fd530d3
No known key found for this signature in database
GPG Key ID: 8E861F8CE6E7CE27

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

@ -29,6 +29,8 @@ import org.koitharu.kotatsu.tracker.data.TrackEntity
import org.koitharu.kotatsu.tracker.data.TrackLogEntity
import org.koitharu.kotatsu.tracker.data.TracksDao
const val DATABASE_VERSION = 12
@Database(
entities = [
MangaEntity::class, TagEntity::class, HistoryEntity::class, MangaTagsEntity::class,
@ -36,7 +38,7 @@ import org.koitharu.kotatsu.tracker.data.TracksDao
TrackEntity::class, TrackLogEntity::class, SuggestionEntity::class, BookmarkEntity::class,
ScrobblingEntity::class,
],
version = 12,
version = DATABASE_VERSION,
)
abstract class MangaDatabase : RoomDatabase() {

Loading…
Cancel
Save