Skip to content

Commit e8dbda3

Browse files
authored
test: add test for parsing version components (#1833)
It reveals a bug found by @Vampire and being fixed in #1831. This PR adds proper, direct visibility to the current behavior.
1 parent 6d7a4c8 commit e8dbda3

File tree

1 file changed

+24
-0
lines changed
  • shared-internal/src/test/kotlin/io/github/typesafegithub/workflows/shared/internal/model

1 file changed

+24
-0
lines changed

shared-internal/src/test/kotlin/io/github/typesafegithub/workflows/shared/internal/model/VersionTest.kt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,34 @@
11
package io.github.typesafegithub.workflows.shared.internal.model
22

3+
import io.kotest.assertions.assertSoftly
34
import io.kotest.core.spec.style.FunSpec
45
import io.kotest.matchers.shouldBe
56

67
class VersionTest :
78
FunSpec({
9+
context("parsing") {
10+
listOf(
11+
Pair("v1.2.3", Triple(1, 2, 3)),
12+
Pair("1.2.3", Triple(1, 2, 3)),
13+
Pair("v1.2.3.4", Triple(1, 2, 4)),
14+
Pair("1.2.3.4", Triple(1, 2, 4)),
15+
Pair("v1.2", Triple(1, 2, 2)),
16+
Pair("v3", Triple(3, 3, 3)),
17+
Pair("V3", Triple(3, 3, 3)),
18+
Pair("v3-prerelease", Triple(0, 0, 0)),
19+
Pair("beta-v3", Triple(0, 0, 0)),
20+
).forEach { (string, version) ->
21+
test("correctly parses $string") {
22+
val parsedVersion = Version(string)
23+
assertSoftly {
24+
parsedVersion.major shouldBe version.first
25+
parsedVersion.minor shouldBe version.second
26+
parsedVersion.patch shouldBe version.third
27+
}
28+
}
29+
}
30+
}
31+
832
context("isMajorVersion") {
933
listOf(
1034
Pair("v1.2.3", false),

0 commit comments

Comments
 (0)