Skip to content

Commit

Permalink
no need to overload the File version, it's working well
Browse files Browse the repository at this point in the history
  • Loading branch information
martinbonnin committed Jan 7, 2024
1 parent a9f3f7a commit 4a3bba2
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import io.kotest.matchers.shouldBe
import io.kotest.matchers.string.shouldContain
import io.kotest.matchers.string.shouldNotContain
import java.io.File
import shouldBeAnExistingFile
import shouldBeAFile

class KotlinMultiplatformExampleTest : FunSpec({

Expand Down Expand Up @@ -106,7 +106,7 @@ class KotlinMultiplatformExampleTest : FunSpec({
dokkatooProject
.findFiles { it.name == "dokka-worker.log" }
.shouldBeSingleton { dokkaWorkerLog ->
dokkaWorkerLog.shouldBeAnExistingFile()
dokkaWorkerLog.shouldBeAFile()
dokkaWorkerLog.readText().shouldNotContainAnyOf(
"[ERROR]",
"[WARN]",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import io.kotest.matchers.string.shouldContain
import io.kotest.matchers.string.shouldNotContain
import java.io.File
import org.gradle.testkit.runner.TaskOutcome.UP_TO_DATE
import shouldBeAnExistingFile
import shouldBeAFile

class MultimoduleExampleTest : FunSpec({

Expand Down Expand Up @@ -59,7 +59,7 @@ class MultimoduleExampleTest : FunSpec({
dokkatooProject
.findFiles { it.name == "dokka-worker.log" }
.shouldForAll { dokkaWorkerLog ->
dokkaWorkerLog.shouldBeAnExistingFile()
dokkaWorkerLog.shouldBeAFile()
dokkaWorkerLog.readText().shouldNotContainAnyOf(
"[ERROR]",
"[WARN]",
Expand Down Expand Up @@ -108,7 +108,7 @@ class MultimoduleExampleTest : FunSpec({
dokkatooProject
.findFiles { it.name == "dokka-worker.log" }
.shouldForAll { dokkaWorkerLog ->
dokkaWorkerLog.shouldBeAnExistingFile()
dokkaWorkerLog.shouldBeAFile()
dokkaWorkerLog.readText().shouldNotContainAnyOf(
"[ERROR]",
"[WARN]",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import dev.adamko.dokkatoo.utils.*
import io.kotest.assertions.withClue
import io.kotest.core.spec.style.FunSpec
import io.kotest.inspectors.shouldForAll
import io.kotest.matchers.file.shouldBeAFile
import io.kotest.matchers.sequences.shouldNotBeEmpty
import io.kotest.matchers.string.shouldContain
import io.kotest.matchers.string.shouldNotContain
Expand All @@ -31,7 +32,7 @@ class KotlinMultiplatformFunctionalTest : FunSpec({
project
.findFiles { it.name == "dokka-worker.log" }
.shouldBeSingleton { dokkaWorkerLog ->
dokkaWorkerLog.shouldBeAnExistingFile()
dokkaWorkerLog.shouldBeAFile()
dokkaWorkerLog.readText().shouldNotContainAnyOf(
"[ERROR]",
"[WARN]",
Expand All @@ -53,7 +54,7 @@ class KotlinMultiplatformFunctionalTest : FunSpec({
// }

test("with element-list") {
project.projectDir.resolve("build/dokka/html/test/package-list").shouldBeAnExistingFile()
project.projectDir.resolve("build/dokka/html/test/package-list").shouldBeAFile()
project.projectDir.resolve("build/dokka/html/test/package-list").toFile().readText()
.sortLines()
.shouldContain( /* language=text */ """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import io.kotest.core.spec.style.FunSpec
import io.kotest.inspectors.shouldForAll
import io.kotest.matchers.collections.shouldBeIn
import io.kotest.matchers.collections.shouldContainAll
import io.kotest.matchers.file.shouldBeAFile
import io.kotest.matchers.paths.shouldNotExist
import io.kotest.matchers.string.shouldBeEmpty
import io.kotest.matchers.string.shouldContain
Expand Down Expand Up @@ -34,7 +35,7 @@ class MultiModuleFunctionalTest : FunSpec({
project
.findFiles { it.name == "dokka-worker.log" }
.shouldForAll { dokkaWorkerLog ->
dokkaWorkerLog.shouldBeAnExistingFile()
dokkaWorkerLog.shouldBeAFile()
dokkaWorkerLog.readText().shouldNotContainAnyOf(
"[ERROR]",
"[WARN]",
Expand All @@ -56,7 +57,7 @@ class MultiModuleFunctionalTest : FunSpec({
// }

test("with element-list") {
project.file("build/dokka/html/package-list").shouldBeAnExistingFile()
project.file("build/dokka/html/package-list").shouldBeAFile()
project.file("build/dokka/html/package-list").toFile().readText()
.shouldContain( /* language=text */ """
|${'$'}dokka.format:html-v1
Expand Down Expand Up @@ -100,7 +101,7 @@ class MultiModuleFunctionalTest : FunSpec({
project
.findFiles { it.name == "dokka-worker.log" }
.shouldForAll { dokkaWorkerLog ->
dokkaWorkerLog.shouldBeAnExistingFile()
dokkaWorkerLog.shouldBeAFile()
dokkaWorkerLog.readText().shouldNotContainAnyOf(
"[ERROR]",
"[WARN]",
Expand Down Expand Up @@ -166,7 +167,7 @@ class MultiModuleFunctionalTest : FunSpec({
project
.findFiles { it.name == "dokka-worker.log" }
.shouldForAll { dokkaWorkerLog ->
dokkaWorkerLog.shouldBeAnExistingFile()
dokkaWorkerLog.shouldBeAFile()
dokkaWorkerLog.readText().shouldNotContainAnyOf(
"[ERROR]",
"[WARN]",
Expand Down Expand Up @@ -229,7 +230,7 @@ class MultiModuleFunctionalTest : FunSpec({
.build {

test("expect HelloAgain HTML file exists") {
helloAgainIndexHtml.shouldBeAnExistingFile()
helloAgainIndexHtml.shouldBeAFile()
}

test("expect :subproject-goodbye tasks are up-to-date, because no files changed") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@ import io.kotest.matchers.paths.shouldExist
import java.io.File
import java.nio.file.Path

internal fun Path.shouldBeAnExistingFile(): Unit = run {
internal fun Path.shouldBeAFile(): Unit = run {
shouldExist()
shouldBeAFile()
}

internal fun File.shouldBeAnExistingFile(): Unit = run {
shouldExist()
shouldBeAFile()
}

0 comments on commit 4a3bba2

Please sign in to comment.