Refactor tracker and add tests

This commit is contained in:
Koitharu
2022-06-16 15:26:57 +03:00
parent 3edfd0892a
commit c82bacb037
30 changed files with 1070 additions and 308 deletions

View File

@@ -1,32 +0,0 @@
package org.koitharu.kotatsu.utils
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.test.StandardTestDispatcher
import kotlinx.coroutines.test.TestDispatcher
import kotlinx.coroutines.test.resetMain
import kotlinx.coroutines.test.setMain
import org.junit.rules.TestWatcher
import org.junit.runner.Description
class CoroutineTestRule(
private val testDispatcher: TestDispatcher = StandardTestDispatcher(),
) : TestWatcher() {
override fun starting(description: Description) {
super.starting(description)
Dispatchers.setMain(testDispatcher)
}
override fun finished(description: Description) {
super.finished(description)
Dispatchers.resetMain()
}
fun runBlockingTest(block: suspend CoroutineScope.() -> Unit) {
runBlocking(testDispatcher) {
block()
}
}
}