|
| 1 | +package io.github.typesafegithub.workflows.mavenbinding |
| 2 | + |
| 3 | +import io.github.typesafegithub.workflows.actionbindinggenerator.domain.ActionCoords |
| 4 | +import io.github.typesafegithub.workflows.actionbindinggenerator.domain.SignificantVersion |
| 5 | +import io.github.typesafegithub.workflows.actionbindinggenerator.domain.SignificantVersion.COMMIT_LENIENT |
| 6 | +import io.github.typesafegithub.workflows.actionbindinggenerator.domain.SignificantVersion.FULL |
| 7 | +import io.kotest.core.spec.style.FunSpec |
| 8 | +import io.kotest.matchers.shouldBe |
| 9 | + |
| 10 | +class PomBuildingTest : |
| 11 | + FunSpec({ |
| 12 | + SignificantVersion.entries.forEach { significantVersion -> |
| 13 | + test("significant version $significantVersion requested") { |
| 14 | + // given |
| 15 | + val commitLenient = significantVersion == COMMIT_LENIENT |
| 16 | + var nameSuffix = if (significantVersion == FULL) "" else "___$significantVersion" |
| 17 | + var versionSuffix = if (commitLenient) "__commit-sha" else "" |
| 18 | + var prettyPrintSuffix = |
| 19 | + when (significantVersion) { |
| 20 | + FULL -> "" |
| 21 | + COMMIT_LENIENT -> " with $significantVersion version and comment 'v1.2.3'" |
| 22 | + else -> " with $significantVersion version" |
| 23 | + } |
| 24 | + var version = if (commitLenient) "commit-sha" else "v1.2.3" |
| 25 | + |
| 26 | + val bindingsServerRequest = |
| 27 | + BindingsServerRequest( |
| 28 | + rawName = "name$nameSuffix", |
| 29 | + rawVersion = "v1.2.3$versionSuffix", |
| 30 | + actionCoords = |
| 31 | + ActionCoords( |
| 32 | + owner = "owner", |
| 33 | + name = "name", |
| 34 | + version = version, |
| 35 | + comment = if (commitLenient) "v1.2.3" else null, |
| 36 | + significantVersion = significantVersion, |
| 37 | + ), |
| 38 | + ) |
| 39 | + val xml = bindingsServerRequest.buildPomFile() |
| 40 | + |
| 41 | + xml shouldBe |
| 42 | + """ |
| 43 | + <?xml version="1.0" encoding="UTF-8"?> |
| 44 | + <project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> |
| 45 | + <modelVersion>4.0.0</modelVersion> |
| 46 | + <groupId>owner</groupId> |
| 47 | + <artifactId>name$nameSuffix</artifactId> |
| 48 | + <version>v1.2.3$versionSuffix</version> |
| 49 | + <name>name</name> |
| 50 | + <description>Auto-generated binding for owner/name$prettyPrintSuffix@$version.</description> |
| 51 | + <url>https://github.com/owner/name</url> |
| 52 | + <scm> |
| 53 | + <connection>scm:git:git://github.com/owner/name.git/</connection> |
| 54 | + <developerConnection>scm:git:ssh://github.com:owner/name.git</developerConnection> |
| 55 | + <url>https://github.com/owner/name.git</url> |
| 56 | + </scm> |
| 57 | + <dependencies> |
| 58 | + <dependency> |
| 59 | + <groupId>io.github.typesafegithub</groupId> |
| 60 | + <artifactId>github-workflows-kt</artifactId> |
| 61 | + <version>3.7.0</version> |
| 62 | + <scope>compile</scope> |
| 63 | + </dependency> |
| 64 | + </dependencies> |
| 65 | + </project> |
| 66 | + """.trimIndent() |
| 67 | + } |
| 68 | + } |
| 69 | + }) |
0 commit comments