mirror of
https://github.com/wulkanowy/wulkanowy.git
synced 2025-01-31 15:28:20 +01:00
Remove tests deprecations (#2260)
This commit is contained in:
parent
e79c5d4d2b
commit
5b2e2ffb34
@ -2,7 +2,6 @@ apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlinx-serialization'
|
||||
apply plugin: 'kotlin-parcelize'
|
||||
apply plugin: 'kotlin-kapt'
|
||||
apply plugin: 'com.google.devtools.ksp'
|
||||
apply plugin: 'dagger.hilt.android.plugin'
|
||||
apply plugin: 'com.google.gms.google-services'
|
||||
@ -11,6 +10,7 @@ apply plugin: 'com.github.triplet.play'
|
||||
apply plugin: 'ru.cian.huawei-publish'
|
||||
apply plugin: 'com.mikepenz.aboutlibraries.plugin'
|
||||
apply plugin: 'com.huawei.agconnect'
|
||||
apply plugin: 'kotlin-kapt'
|
||||
apply from: 'jacoco.gradle'
|
||||
apply from: 'sonarqube.gradle'
|
||||
apply from: 'hooks.gradle'
|
||||
|
@ -2,7 +2,8 @@ package io.github.wulkanowy
|
||||
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.test.TestCoroutineDispatcher
|
||||
import kotlinx.coroutines.test.TestDispatcher
|
||||
import kotlinx.coroutines.test.UnconfinedTestDispatcher
|
||||
import kotlinx.coroutines.test.resetMain
|
||||
import kotlinx.coroutines.test.setMain
|
||||
import org.junit.rules.TestWatcher
|
||||
@ -10,17 +11,14 @@ import org.junit.runner.Description
|
||||
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
class MainCoroutineRule(
|
||||
private val testDispatcher: TestCoroutineDispatcher = TestCoroutineDispatcher()
|
||||
private val testDispatcher: TestDispatcher = UnconfinedTestDispatcher()
|
||||
) : TestWatcher() {
|
||||
|
||||
override fun starting(description: Description?) {
|
||||
super.starting(description)
|
||||
override fun starting(description: Description) {
|
||||
Dispatchers.setMain(testDispatcher)
|
||||
}
|
||||
|
||||
override fun finished(description: Description?) {
|
||||
super.finished(description)
|
||||
override fun finished(description: Description) {
|
||||
Dispatchers.resetMain()
|
||||
testDispatcher.cleanupTestCoroutines()
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,8 @@ abstract class AbstractMigrationTest {
|
||||
@get:Rule
|
||||
val helper: MigrationTestHelper = MigrationTestHelper(
|
||||
InstrumentationRegistry.getInstrumentation(),
|
||||
AppDatabase::class.java.canonicalName,
|
||||
AppDatabase::class.java,
|
||||
listOf(Migration55()),
|
||||
FrameworkSQLiteOpenHelperFactory()
|
||||
)
|
||||
|
||||
|
@ -22,12 +22,12 @@ class Migration12Test : AbstractMigrationTest() {
|
||||
fun twoNotRelatedStudents() {
|
||||
helper.createDatabase(dbName, 11).apply {
|
||||
// user 1
|
||||
createStudent(this, 1, true)
|
||||
createStudent(this, 1)
|
||||
createSemester(this, 1, false, 5, 1)
|
||||
createSemester(this, 1, true, 5, 2)
|
||||
|
||||
// user 2
|
||||
createStudent(this, 2, true)
|
||||
createStudent(this, 2)
|
||||
createSemester(this, 2, false, 6, 1)
|
||||
createSemester(this, 2, true, 6, 2)
|
||||
close()
|
||||
@ -56,9 +56,9 @@ class Migration12Test : AbstractMigrationTest() {
|
||||
fun removeStudentsWithoutClassId() {
|
||||
helper.createDatabase(dbName, 11).apply {
|
||||
// user 1
|
||||
createStudent(this, 1, true)
|
||||
createStudent(this, 1)
|
||||
createSemester(this, 1, false, 0, 2)
|
||||
createStudent(this, 2, true)
|
||||
createStudent(this, 2)
|
||||
createSemester(this, 2, true, 1, 2)
|
||||
close()
|
||||
}
|
||||
@ -81,11 +81,11 @@ class Migration12Test : AbstractMigrationTest() {
|
||||
fun ensureThereIsOnlyOneCurrentStudent() {
|
||||
helper.createDatabase(dbName, 11).apply {
|
||||
// user 1
|
||||
createStudent(this, 1, true)
|
||||
createStudent(this, 1)
|
||||
createSemester(this, 1, true, 5, 2)
|
||||
createStudent(this, 2, true)
|
||||
createStudent(this, 2)
|
||||
createSemester(this, 2, true, 6, 2)
|
||||
createStudent(this, 3, true)
|
||||
createStudent(this, 3)
|
||||
createSemester(this, 3, false, 7, 2)
|
||||
close()
|
||||
}
|
||||
@ -112,7 +112,7 @@ class Migration12Test : AbstractMigrationTest() {
|
||||
db.close()
|
||||
}
|
||||
|
||||
private fun createStudent(db: SupportSQLiteDatabase, studentId: Int, isCurrent: Boolean) {
|
||||
private fun createStudent(db: SupportSQLiteDatabase, studentId: Int) {
|
||||
db.insert("Students", CONFLICT_FAIL, ContentValues().apply {
|
||||
put("endpoint", "https://fakelog.cf")
|
||||
put("loginType", "STANDARD")
|
||||
@ -123,7 +123,7 @@ class Migration12Test : AbstractMigrationTest() {
|
||||
put("student_name", "Jan Kowalski")
|
||||
put("school_id", "000123")
|
||||
put("school_name", "")
|
||||
put("is_current", isCurrent)
|
||||
put("is_current", true)
|
||||
put("registration_date", "0")
|
||||
})
|
||||
}
|
||||
|
@ -95,22 +95,22 @@ class Migration13Test : AbstractMigrationTest() {
|
||||
fun markAtLeastAndOnlyOneSemesterAtCurrent() {
|
||||
helper.createDatabase(dbName, 12).apply {
|
||||
createStudent(this, 1, "", 5)
|
||||
createSemester(this, 1, 5, 1, 1, false)
|
||||
createSemester(this, 1, 5, 2, 1, false)
|
||||
createSemester(this, 1, 5, 3, 2, false)
|
||||
createSemester(this, 1, 5, 4, 2, false)
|
||||
createSemester(this, 1, 1, 1, false)
|
||||
createSemester(this, 1, 2, 1, false)
|
||||
createSemester(this, 1, 3, 2, false)
|
||||
createSemester(this, 1, 4, 2, false)
|
||||
|
||||
createStudent(this, 2, "", 5)
|
||||
createSemester(this, 2, 5, 5, 5, true)
|
||||
createSemester(this, 2, 5, 6, 5, true)
|
||||
createSemester(this, 2, 5, 7, 55, true)
|
||||
createSemester(this, 2, 5, 8, 55, true)
|
||||
createSemester(this, 2, 5, 5, true)
|
||||
createSemester(this, 2, 6, 5, true)
|
||||
createSemester(this, 2, 7, 55, true)
|
||||
createSemester(this, 2, 8, 55, true)
|
||||
|
||||
createStudent(this, 3, "", 5)
|
||||
createSemester(this, 3, 5, 11, 99, false)
|
||||
createSemester(this, 3, 5, 12, 99, false)
|
||||
createSemester(this, 3, 5, 13, 100, false)
|
||||
createSemester(this, 3, 5, 14, 100, true)
|
||||
createSemester(this, 3, 11, 99, false)
|
||||
createSemester(this, 3, 12, 99, false)
|
||||
createSemester(this, 3, 13, 100, false)
|
||||
createSemester(this, 3, 14, 100, true)
|
||||
close()
|
||||
}
|
||||
|
||||
@ -198,7 +198,13 @@ class Migration13Test : AbstractMigrationTest() {
|
||||
})
|
||||
}
|
||||
|
||||
private fun createSemester(db: SupportSQLiteDatabase, studentId: Int, classId: Int, semesterId: Int, diaryId: Int, isCurrent: Boolean = false) {
|
||||
private fun createSemester(
|
||||
db: SupportSQLiteDatabase,
|
||||
studentId: Int,
|
||||
semesterId: Int,
|
||||
diaryId: Int,
|
||||
isCurrent: Boolean = false
|
||||
) {
|
||||
db.insert("Semesters", SQLiteDatabase.CONFLICT_FAIL, ContentValues().apply {
|
||||
put("student_id", studentId)
|
||||
put("diary_id", diaryId)
|
||||
@ -206,7 +212,7 @@ class Migration13Test : AbstractMigrationTest() {
|
||||
put("semester_id", semesterId)
|
||||
put("semester_name", "1")
|
||||
put("is_current", isCurrent)
|
||||
put("class_id", classId)
|
||||
put("class_id", 5)
|
||||
put("unit_id", "99")
|
||||
})
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user