Skip to content

Commit cd8f0dd

Browse files
Add some more tests (#10)
* Extend TestNewVersion * Extend TestCollection Co-authored-by: Markus <[email protected]>
1 parent 467c127 commit cd8f0dd

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

version_collection_test.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,30 @@ func TestCollection(t *testing.T) {
1313
"1.2",
1414
"2",
1515
"0.7.1",
16+
"1.2.3",
17+
"1",
18+
"1.2-5",
19+
"1.2-beta.5",
20+
"1.2.0-x.Y.0+metadata",
21+
"1.2.0-x.Y.0+metadata-width-hypen",
22+
"1.2.3-rc1-with-hypen",
23+
"1.2.3.4",
24+
"1.2.0.4-x.Y.0+metadata",
25+
"1.2.0.4-x.Y.0+metadata-width-hypen",
26+
"1.2.0-X-1.2.0+metadata~dist",
27+
"1.2.3.4-rc1-with-hypen",
28+
"1.2.3.4",
29+
"V1.2.3",
30+
"1.7rc2",
31+
"v1.7rc2",
32+
"v1.0-",
33+
"2.28.0.618+gf4bc123cb7",
34+
"1.13.0+dev-545-gb3b1c081b",
35+
"2.28.0.618.gf4bc123cb7",
36+
"2.29.0.rc0.261.g7178c9af9c",
37+
"1.2.beta",
38+
"1.21.beta",
39+
"v1.13.0-rc1",
1640
}
1741

1842
versions := make([]*Version, len(versionsRaw))
@@ -34,10 +58,34 @@ func TestCollection(t *testing.T) {
3458

3559
expected := []string{
3660
"0.7.1",
61+
"1.0.0--",
62+
"1.0.0",
3763
"1.0.0",
3864
"1.1.1",
65+
"1.2.0-5",
66+
"1.2.0-X-1.2.0+metadata~dist",
67+
"1.2.0-beta",
68+
"1.2.0-beta.5",
69+
"1.2.0-x.Y.0+metadata",
70+
"1.2.0-x.Y.0+metadata-width-hypen",
3971
"1.2.0",
72+
"1.2.0.4-x.Y.0+metadata",
73+
"1.2.0.4-x.Y.0+metadata-width-hypen",
74+
"1.2.3-rc1-with-hypen",
75+
"1.2.3",
76+
"1.2.3",
77+
"1.2.3.4-rc1-with-hypen",
78+
"1.2.3.4",
79+
"1.2.3.4",
80+
"1.7.0-rc2",
81+
"1.7.0-rc2",
82+
"1.13.0-rc1",
83+
"1.13.0+dev-545-gb3b1c081b",
84+
"1.21.0-beta",
4085
"2.0.0",
86+
"2.28.0.618-gf4bc123cb7",
87+
"2.28.0.618+gf4bc123cb7",
88+
"2.29.0-rc0.261.g7178c9af9c",
4189
}
4290

4391
if !reflect.DeepEqual(actual, expected) {

version_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,20 @@ func TestNewVersion(t *testing.T) {
3535
{"2.29.0.rc0.261.g7178c9af9c", false},
3636
{"1.2.beta", false},
3737
{"1.21.beta", false},
38+
{"v1.13.0-rc1", false},
3839

3940
// Have Error
4041
{"", true},
4142
{"foo", true},
4243
{"\n1.2", true},
4344
{"foo1.2.3", true},
45+
{"\n", true},
46+
{".", true},
47+
{"beta", true},
48+
{"v", true},
49+
{"+metadata-width-hypen", true},
50+
{"+metadata~dist", true},
51+
{"-rc1-with-hypen", true},
4452
}
4553

4654
for _, tc := range cases {

0 commit comments

Comments
 (0)