Update manga parsers
This commit is contained in:
@@ -6,6 +6,7 @@ import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.junit.runners.Parameterized
|
||||
import org.koin.core.component.inject
|
||||
import org.koin.core.logger.Level
|
||||
import org.koin.core.parameter.parametersOf
|
||||
import org.koin.test.KoinTest
|
||||
import org.koin.test.KoinTestRule
|
||||
@@ -18,7 +19,7 @@ import org.koitharu.kotatsu.utils.TestResponse
|
||||
import org.koitharu.kotatsu.utils.ext.mapToSet
|
||||
import org.koitharu.kotatsu.utils.ext.medianOrNull
|
||||
import org.koitharu.kotatsu.utils.isAbsoluteUrl
|
||||
import org.koitharu.kotatsu.utils.isRelativeUrl
|
||||
import org.koitharu.kotatsu.utils.isNotAbsoluteUrl
|
||||
|
||||
@RunWith(Parameterized::class)
|
||||
class RemoteMangaRepositoryTest(private val source: MangaSource) : KoinTest {
|
||||
@@ -29,7 +30,7 @@ class RemoteMangaRepositoryTest(private val source: MangaSource) : KoinTest {
|
||||
|
||||
@get:Rule
|
||||
val koinTestRule = KoinTestRule.create {
|
||||
printLogger()
|
||||
printLogger(Level.ERROR)
|
||||
modules(repositoryTestModule)
|
||||
}
|
||||
|
||||
@@ -112,7 +113,7 @@ class RemoteMangaRepositoryTest(private val source: MangaSource) : KoinTest {
|
||||
Truth.assertThat(list.map { it.id }).containsNoDuplicates()
|
||||
for (item in list) {
|
||||
Truth.assertThat(item.url).isNotEmpty()
|
||||
Truth.assertThat(item.url).isRelativeUrl()
|
||||
Truth.assertThat(item.url).isNotAbsoluteUrl()
|
||||
Truth.assertThat(item.coverUrl).isAbsoluteUrl()
|
||||
Truth.assertThat(item.title).isNotEmpty()
|
||||
Truth.assertThat(item.publicUrl).isAbsoluteUrl()
|
||||
|
||||
@@ -3,25 +3,25 @@ package org.koitharu.kotatsu.utils
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.coroutines.test.TestCoroutineDispatcher
|
||||
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: TestCoroutineDispatcher = TestCoroutineDispatcher(),
|
||||
private val testDispatcher: TestDispatcher = StandardTestDispatcher(),
|
||||
) : TestWatcher() {
|
||||
|
||||
override fun starting(description: Description?) {
|
||||
override fun starting(description: Description) {
|
||||
super.starting(description)
|
||||
Dispatchers.setMain(testDispatcher)
|
||||
}
|
||||
|
||||
override fun finished(description: Description?) {
|
||||
override fun finished(description: Description) {
|
||||
super.finished(description)
|
||||
Dispatchers.resetMain()
|
||||
testDispatcher.cleanupTestCoroutines()
|
||||
}
|
||||
|
||||
fun runBlockingTest(block: suspend CoroutineScope.() -> Unit) {
|
||||
|
||||
@@ -8,4 +8,6 @@ private val PATTERN_URL_RELATIVE = Pattern.compile("^/[^\\s]+", Pattern.CASE_INS
|
||||
|
||||
fun StringSubject.isRelativeUrl() = matches(PATTERN_URL_RELATIVE)
|
||||
|
||||
fun StringSubject.isAbsoluteUrl() = matches(PATTERN_URL_ABSOLUTE)
|
||||
fun StringSubject.isAbsoluteUrl() = matches(PATTERN_URL_ABSOLUTE)
|
||||
|
||||
fun StringSubject.isNotAbsoluteUrl() = doesNotMatch(PATTERN_URL_ABSOLUTE)
|
||||
Reference in New Issue
Block a user