Skip to content

Commit 9321528

Browse files
committed
Review Feedback Vol. 1
1 parent 6d48637 commit 9321528

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

maven-binding-builder/src/test/kotlin/io/github/typesafegithub/workflows/mavenbinding/MavenMetadataBuildingTest.kt

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package io.github.typesafegithub.workflows.mavenbinding
22

33
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.FULL
46
import io.github.typesafegithub.workflows.shared.internal.model.Version
57
import io.kotest.core.spec.style.FunSpec
68
import io.kotest.matchers.nulls.shouldBeNull
@@ -91,4 +93,52 @@ class MavenMetadataBuildingTest :
9193

9294
xml.shouldBeNull()
9395
}
96+
97+
(SignificantVersion.entries - FULL).forEach { significantVersion ->
98+
test("significant version $significantVersion requested") {
99+
// Given
100+
val fetchAvailableVersions: suspend (String, String, String?) -> List<Version> = { owner, name, _ ->
101+
listOf(
102+
Version(version = "v3-beta", dateProvider = { ZonedDateTime.parse("2024-07-01T00:00:00Z") }),
103+
Version(version = "v2", dateProvider = { ZonedDateTime.parse("2024-05-01T00:00:00Z") }),
104+
Version(version = "v1", dateProvider = { ZonedDateTime.parse("2024-03-07T00:00:00Z") }),
105+
Version(version = "v1.1", dateProvider = { ZonedDateTime.parse("2024-03-07T00:00:00Z") }),
106+
Version(version = "v1.1.0", dateProvider = { ZonedDateTime.parse("2024-03-07T00:00:00Z") }),
107+
Version(version = "v1.0.1", dateProvider = { ZonedDateTime.parse("2024-03-05T00:00:00Z") }),
108+
Version(version = "v1.0", dateProvider = { ZonedDateTime.parse("2024-03-01T00:00:00Z") }),
109+
Version(version = "v1.0.0", dateProvider = { ZonedDateTime.parse("2024-03-01T00:00:00Z") }),
110+
)
111+
}
112+
113+
val xml =
114+
actionCoords.copy(significantVersion = significantVersion).buildMavenMetadataFile(
115+
githubToken = "SOME_TOKEN",
116+
fetchAvailableVersions = fetchAvailableVersions,
117+
)
118+
119+
xml shouldBe
120+
"""
121+
<?xml version="1.0" encoding="UTF-8"?>
122+
<metadata>
123+
<groupId>owner</groupId>
124+
<artifactId>name___$significantVersion</artifactId>
125+
<versioning>
126+
<latest>v2</latest>
127+
<release>v2</release>
128+
<versions>
129+
<version>v3-beta</version>
130+
<version>v2</version>
131+
<version>v1</version>
132+
<version>v1.1</version>
133+
<version>v1.1.0</version>
134+
<version>v1.0.1</version>
135+
<version>v1.0</version>
136+
<version>v1.0.0</version>
137+
</versions>
138+
<lastUpdated>20240501000000</lastUpdated>
139+
</versioning>
140+
</metadata>
141+
""".trimIndent()
142+
}
143+
}
94144
})

0 commit comments

Comments
 (0)