Skip to content

Commit 8be4f08

Browse files
authored
test(abg): make generation test able to update multiple files in one test case (#1630)
1 parent bb9468d commit 8be4f08

File tree

2 files changed

+15
-9
lines changed
  • action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator

2 files changed

+15
-9
lines changed

action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/Utils.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package io.github.typesafegithub.workflows.actionbindinggenerator
22

33
import io.github.typesafegithub.workflows.actionbindinggenerator.generation.ActionBinding
4-
import io.kotest.assertions.fail
4+
import io.kotest.matchers.Matcher.Companion.failure
55
import io.kotest.matchers.shouldBe
66
import java.nio.file.Paths
77

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

action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/generation/GenerationTest.kt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import io.github.typesafegithub.workflows.actionbindinggenerator.typing.IntegerW
1616
import io.github.typesafegithub.workflows.actionbindinggenerator.typing.ListOfTypings
1717
import io.github.typesafegithub.workflows.actionbindinggenerator.typing.StringTyping
1818
import io.github.typesafegithub.workflows.actionbindinggenerator.typing.Typing
19+
import io.kotest.assertions.assertSoftly
1920
import io.kotest.core.spec.style.FunSpec
2021
import io.kotest.matchers.collections.shouldHaveSize
2122

@@ -221,8 +222,10 @@ class GenerationTest :
221222
)
222223

223224
// then
224-
binding.shouldContainAndMatchFile("ActionWithAllTypesOfInputs.kt")
225-
binding.shouldContainAndMatchFile("ActionWithAllTypesOfInputs_Untyped.kt")
225+
assertSoftly {
226+
binding.shouldContainAndMatchFile("ActionWithAllTypesOfInputs.kt")
227+
binding.shouldContainAndMatchFile("ActionWithAllTypesOfInputs_Untyped.kt")
228+
}
226229
}
227230

228231
test("action with outputs") {
@@ -471,8 +474,10 @@ class GenerationTest :
471474
)
472475

473476
// then
474-
binding.shouldContainAndMatchFile("ActionWithPartlyTypings.kt")
475-
binding.shouldContainAndMatchFile("ActionWithPartlyTypings_Untyped.kt")
477+
assertSoftly {
478+
binding.shouldContainAndMatchFile("ActionWithPartlyTypings.kt")
479+
binding.shouldContainAndMatchFile("ActionWithPartlyTypings_Untyped.kt")
480+
}
476481
}
477482
})
478483

0 commit comments

Comments
 (0)