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.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(),
) )
} }
} }

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

Loading…
Cancel
Save