From 8be4f087dbe9d55fa756b6f4c13a2d404f4576b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kautler?= Date: Mon, 26 Aug 2024 17:55:32 +0200 Subject: [PATCH] test(abg): make generation test able to update multiple files in one test case (#1630) --- .../workflows/actionbindinggenerator/Utils.kt | 11 ++++++----- .../generation/GenerationTest.kt | 13 +++++++++---- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/Utils.kt b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/Utils.kt index 63f2046cd2..acd65820de 100644 --- a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/Utils.kt +++ b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/Utils.kt @@ -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 @@ -27,10 +27,11 @@ fun List.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( + "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.", + ) } } diff --git a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/generation/GenerationTest.kt b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/generation/GenerationTest.kt index f7769c10d0..4e08800962 100644 --- a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/generation/GenerationTest.kt +++ b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/generation/GenerationTest.kt @@ -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 @@ -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") { @@ -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") + } } })