Skip to content

Commit

Permalink
test(abg): make generation test able to update multiple files in one …
Browse files Browse the repository at this point in the history
…test case (#1630)
  • Loading branch information
Vampire authored Aug 26, 2024
1 parent bb9468d commit 8be4f08
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.github.typesafegithub.workflows.actionbindinggenerator

import io.github.typesafegithub.workflows.actionbindinggenerator.generation.ActionBinding
import io.kotest.assertions.fail
import io.kotest.matchers.Matcher.Companion.failure
import io.kotest.matchers.shouldBe
import java.nio.file.Paths

Expand All @@ -27,10 +27,11 @@ fun List<ActionBinding>.shouldContainAndMatchFile(path: String) {
actualContent shouldBe expectedContent
} else if (actualContent != expectedContent) {
file.writeText(actualContent)
fail(
"The binding's Kotlin code in ${file.name} doesn't match the expected one.\n" +
"The file has been updated to match what's expected.",
)
actualContent shouldBe
failure<Nothing>(
"The binding's Kotlin code in ${file.name} doesn't match the expected one.\n" +
"The file has been updated to match what's expected.",
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import io.github.typesafegithub.workflows.actionbindinggenerator.typing.IntegerW
import io.github.typesafegithub.workflows.actionbindinggenerator.typing.ListOfTypings
import io.github.typesafegithub.workflows.actionbindinggenerator.typing.StringTyping
import io.github.typesafegithub.workflows.actionbindinggenerator.typing.Typing
import io.kotest.assertions.assertSoftly
import io.kotest.core.spec.style.FunSpec
import io.kotest.matchers.collections.shouldHaveSize

Expand Down Expand Up @@ -221,8 +222,10 @@ class GenerationTest :
)

// then
binding.shouldContainAndMatchFile("ActionWithAllTypesOfInputs.kt")
binding.shouldContainAndMatchFile("ActionWithAllTypesOfInputs_Untyped.kt")
assertSoftly {
binding.shouldContainAndMatchFile("ActionWithAllTypesOfInputs.kt")
binding.shouldContainAndMatchFile("ActionWithAllTypesOfInputs_Untyped.kt")
}
}

test("action with outputs") {
Expand Down Expand Up @@ -471,8 +474,10 @@ class GenerationTest :
)

// then
binding.shouldContainAndMatchFile("ActionWithPartlyTypings.kt")
binding.shouldContainAndMatchFile("ActionWithPartlyTypings_Untyped.kt")
assertSoftly {
binding.shouldContainAndMatchFile("ActionWithPartlyTypings.kt")
binding.shouldContainAndMatchFile("ActionWithPartlyTypings_Untyped.kt")
}
}
})

Expand Down

0 comments on commit 8be4f08

Please sign in to comment.