-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…le-migration-test Feature/#89 시간표 데이터베이스 마이그레이션 테스트 코드 작성
- Loading branch information
Showing
12 changed files
with
83 additions
and
38 deletions.
There are no files selected for viewing
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
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
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
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
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
22 changes: 0 additions & 22 deletions
22
core/database/src/androidTest/java/com/suwiki/database/ExampleInstrumentedTest.kt
This file was deleted.
Oops, something went wrong.
55 changes: 55 additions & 0 deletions
55
core/database/src/androidTest/java/com/suwiki/database/TimetableDatabaseMigrate1To2Test.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.suwiki.database | ||
|
||
import androidx.room.testing.MigrationTestHelper | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import androidx.test.platform.app.InstrumentationRegistry | ||
import com.suwiki.core.database.database.TimetableDatabase | ||
import com.suwiki.core.database.database.migration.TIMETABLE_MIGRATION_1_2 | ||
import com.suwiki.core.database.di.DatabaseName | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import java.io.IOException | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
class TimetableDatabaseMigrate1To2Test { | ||
|
||
@get:Rule | ||
val helper: MigrationTestHelper = MigrationTestHelper( | ||
InstrumentationRegistry.getInstrumentation(), | ||
TimetableDatabase::class.java, | ||
) | ||
|
||
@Test | ||
@Throws(IOException::class) | ||
fun testTimetableDBMigrate1To2() { | ||
var db = helper.createDatabase(DatabaseName.TIMETABLE, 1).apply { | ||
val testCellList = """ | ||
[ | ||
{"color":-9728172,"credit":"","day":"목","endTime":"4","location":"미래520","name":"도전과창조-기업가정신","professor":"김기선","startTime":"3"}, | ||
{"color":-4026526,"credit":"","day":"화","endTime":"6","location":"미래520","name":"도전과창조-기업가정신","professor":"홍태민","startTime":"5"}, | ||
{"color":-96120,"credit":"","day":"화","endTime":"1","location":"인문407","name":"언어와문화(이러닝)","professor":"김동섭","startTime":"1"}, | ||
{"color":-96120,"credit":"","day":"토","endTime":"4","location":"인문407","name":"언어와문화(이러닝)","professor":"김동섭","startTime":"3"}, | ||
{"color":-12363882,"credit":"","day":"","endTime":"","location":"이러닝","name":"도전과창조-기업가정신","professor":"김기선","startTime":""}, | ||
{"color":-6194752,"credit":"","day":"토","endTime":"6","location":"미래520","name":"도전과창조-기업가정신","professor":"김기선","startTime":"5"} | ||
] | ||
""".trimIndent() | ||
|
||
execSQL( | ||
""" | ||
INSERT INTO TimetableList (createTime, year, semester, timeTableName, timeTableJsonData) | ||
VALUES ('1706152141568', '2024', '1', '테스트 시간표 이름', '$testCellList') | ||
""".trimIndent(), | ||
) | ||
|
||
close() | ||
} | ||
|
||
db = helper.runMigrationsAndValidate( | ||
/* name = */ DatabaseName.TIMETABLE, | ||
/* version = */ 1, | ||
/* validateDroppedTables = */ true, | ||
/* ...migrations = */ TIMETABLE_MIGRATION_1_2, | ||
) | ||
} | ||
} |
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
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
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
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
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