From f961d326f71099a0b2c74bbf7c7c6d7b3f9f1d51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kautler?= Date: Wed, 22 Apr 2026 17:12:15 +0200 Subject: [PATCH] test(server): Test correct generation of pom files --- .../workflows/mavenbinding/PomBuildingTest.kt | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 maven-binding-builder/src/test/kotlin/io/github/typesafegithub/workflows/mavenbinding/PomBuildingTest.kt diff --git a/maven-binding-builder/src/test/kotlin/io/github/typesafegithub/workflows/mavenbinding/PomBuildingTest.kt b/maven-binding-builder/src/test/kotlin/io/github/typesafegithub/workflows/mavenbinding/PomBuildingTest.kt new file mode 100644 index 0000000000..2a16652abb --- /dev/null +++ b/maven-binding-builder/src/test/kotlin/io/github/typesafegithub/workflows/mavenbinding/PomBuildingTest.kt @@ -0,0 +1,69 @@ +package io.github.typesafegithub.workflows.mavenbinding + +import io.github.typesafegithub.workflows.actionbindinggenerator.domain.ActionCoords +import io.github.typesafegithub.workflows.actionbindinggenerator.domain.SignificantVersion +import io.github.typesafegithub.workflows.actionbindinggenerator.domain.SignificantVersion.COMMIT_LENIENT +import io.github.typesafegithub.workflows.actionbindinggenerator.domain.SignificantVersion.FULL +import io.kotest.core.spec.style.FunSpec +import io.kotest.matchers.shouldBe + +class PomBuildingTest : + FunSpec({ + SignificantVersion.entries.forEach { significantVersion -> + test("significant version $significantVersion requested") { + // given + val commitLenient = significantVersion == COMMIT_LENIENT + var nameSuffix = if (significantVersion == FULL) "" else "___$significantVersion" + var versionSuffix = if (commitLenient) "__commit-sha" else "" + var prettyPrintSuffix = + when (significantVersion) { + FULL -> "" + COMMIT_LENIENT -> " with $significantVersion version and comment 'v1.2.3'" + else -> " with $significantVersion version" + } + var version = if (commitLenient) "commit-sha" else "v1.2.3" + + val bindingsServerRequest = + BindingsServerRequest( + rawName = "name$nameSuffix", + rawVersion = "v1.2.3$versionSuffix", + actionCoords = + ActionCoords( + owner = "owner", + name = "name", + version = version, + comment = if (commitLenient) "v1.2.3" else null, + significantVersion = significantVersion, + ), + ) + val xml = bindingsServerRequest.buildPomFile() + + xml shouldBe + """ + + + 4.0.0 + owner + name$nameSuffix + v1.2.3$versionSuffix + name + Auto-generated binding for owner/name$prettyPrintSuffix@$version. + https://github.com/owner/name + + scm:git:git://github.com/owner/name.git/ + scm:git:ssh://github.com:owner/name.git + https://github.com/owner/name.git + + + + io.github.typesafegithub + github-workflows-kt + 3.7.0 + compile + + + + """.trimIndent() + } + } + })