Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tests #226

Merged
merged 1 commit into from
Oct 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ First Build the jar, then cd into the `scripts` directory and run `./windows-bun
## Running in development mode
run `./gradlew :server:run --stacktrace` to run the server

## Running tests
run `./gradlew :server:test` to execute all tests
to test a specific class run `./gradlew :server:test --tests <package.with.classname>`

## Building the android-jar maven repository
Run `AndroidCompat/getAndroid.sh`(macOS/Linux) or `AndroidCompat/getAndroid.ps1`(Windows)
from project's root directory to download and rebuild the jar file from Google's repository,
Expand Down
6 changes: 5 additions & 1 deletion server/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,11 @@ tasks {
}

test {
useJUnit()
useJUnitPlatform()
testLogging {
showStandardStreams = true
events("passed", "skipped", "failed")
}
}

named<Copy>("processResources") {
Expand Down
15 changes: 8 additions & 7 deletions server/src/test/kotlin/suwayomi/TestExtensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import suwayomi.tachidesk.manga.impl.util.lang.awaitSingle
import suwayomi.tachidesk.manga.impl.util.source.GetCatalogueSource.getCatalogueSource
import suwayomi.tachidesk.manga.model.dataclass.ExtensionDataClass
import suwayomi.tachidesk.server.applicationSetup
import xyz.nulldev.ts.config.CONFIG_PREFIX
import java.io.File
import java.util.concurrent.atomic.AtomicInteger

Expand All @@ -48,8 +49,8 @@ class TestExtensions {

@BeforeAll
fun setup() {
val dataRoot = File("tmp/TestDesk").absolutePath
System.setProperty("suwayomi.tachidesk.server.rootDir", dataRoot)
val dataRoot = File(BASE_PATH).absolutePath
System.setProperty("$CONFIG_PREFIX.server.rootDir", dataRoot)
applicationSetup()
setLoggingEnabled(false)

Expand All @@ -72,7 +73,7 @@ class TestExtensions {
sources = getSourceList().map { getCatalogueSource(it.id.toLong())!! as HttpSource }
}
setLoggingEnabled(true)
File("tmp/TestDesk/sources.txt").writeText(sources.joinToString("\n") { "${it.name} - ${it.lang.uppercase()} - ${it.id}" })
File("$BASE_PATH/sources.txt").writeText(sources.joinToString("\n") { "${it.name} - ${it.lang.uppercase()} - ${it.id}" })
}

@Test
Expand All @@ -97,7 +98,7 @@ class TestExtensions {
}
}
}.awaitAll()
File("tmp/TestDesk/failedToFetch.txt").writeText(
File("$BASE_PATH/failedToFetch.txt").writeText(
failedToFetch.joinToString("\n") { (source, exception) ->
"${source.name} (${source.lang.uppercase()}, ${source.id}):" +
" ${exception.message}"
Expand All @@ -122,7 +123,7 @@ class TestExtensions {
}
}
}.awaitAll()
File("tmp/TestDesk/MangaFailedToFetch.txt").writeText(
File("$BASE_PATH/MangaFailedToFetch.txt").writeText(
mangaFailedToFetch.joinToString("\n") { (source, manga, exception) ->
"${source.name} (${source.lang}, ${source.id}):" +
" ${manga.title} (${source.mangaDetailsRequest(manga).url}):" +
Expand Down Expand Up @@ -157,7 +158,7 @@ class TestExtensions {
}
}.awaitAll()

File("tmp/TestDesk/ChaptersFailedToFetch.txt").writeText(
File("$BASE_PATH/ChaptersFailedToFetch.txt").writeText(
chaptersFailedToFetch.joinToString("\n") { (source, manga, exception) ->
"${source.name} (${source.lang}, ${source.id}):" +
" ${manga.title} (${source.mangaDetailsRequest(manga).url}):" +
Expand All @@ -182,7 +183,7 @@ class TestExtensions {
}
}.awaitAll()

File("tmp/TestDesk/ChapterPageListFailedToFetch.txt").writeText(
File("$BASE_PATH/ChapterPageListFailedToFetch.txt").writeText(
chaptersPageListFailedToFetch.joinToString("\n") { (source, manga, exception) ->
"${source.name} (${source.lang}, ${source.id}):" +
" ${manga.first.title} (${source.mangaDetailsRequest(manga.first).url}):" +
Expand Down
2 changes: 2 additions & 0 deletions server/src/test/kotlin/suwayomi/TestUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ fun setLoggingEnabled(enabled: Boolean = true) {
Level.DEBUG
} else Level.ERROR
}

const val BASE_PATH = "build/tmp/TestDesk"