|
1 | 1 | package io.github.typesafegithub.workflows.mavenbinding
|
2 | 2 |
|
3 | 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.FULL |
4 | 6 | import io.github.typesafegithub.workflows.shared.internal.model.Version
|
5 | 7 | import io.kotest.core.spec.style.FunSpec
|
6 | 8 | import io.kotest.matchers.nulls.shouldBeNull
|
@@ -91,4 +93,52 @@ class MavenMetadataBuildingTest :
|
91 | 93 |
|
92 | 94 | xml.shouldBeNull()
|
93 | 95 | }
|
| 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 | + } |
94 | 144 | })
|
0 commit comments