-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathbumper_test.go
78 lines (67 loc) · 1.89 KB
/
bumper_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package autotag
import (
"testing"
"github.com/hashicorp/go-version"
)
// whitebox testing for autotag bump interface
func TestMinorBumper(t *testing.T) {
for k, v := range map[string]string{
"1": "1.1.0",
"1.0": "1.1.0",
"1.0.0": "1.1.0",
"1.0.12": "1.1.0",
"1.0.0-patch": "1.1.0",
"1.0.0+build123": "1.1.0",
"1.0.0+build123.foo": "1.1.0",
"1.0.0.0": "1.1.0",
} {
tv, err := version.NewVersion(k)
checkFatal(t, err)
nv, err := minorBumper.bump(tv)
checkFatal(t, err)
if nv.String() != v {
t.Fatalf("Expected '%s' got '%s'", v, nv.String())
}
}
}
func TestPatchBumper(t *testing.T) {
// in retro this didn't have to be a map, but w/e
for k, v := range map[string]string{
"1": "1.0.1",
"1.0": "1.0.1",
"1.0.0": "1.0.1",
"1.0.0-patch": "1.0.1",
"1.0.0+build123": "1.0.1",
"1.0.0+build123.foo.bar": "1.0.1",
"1.0.0.0": "1.0.1.0", // XXX: this passes tests but is it correct? SemVer doesn't specify behavior 4 for digit versions
} {
tv, err := version.NewVersion(k)
checkFatal(t, err)
nv, err := patchBumper.bump(tv)
checkFatal(t, err)
if nv.String() != v {
t.Fatalf("Expected '%s' got '%s'", v, nv.String())
}
}
}
func TestMajorBumper(t *testing.T) {
for k, v := range map[string]string{
"1": "2.0.0",
"1.0": "2.0.0",
"1.1": "2.0.0",
"1.0.0": "2.0.0",
"1.1.0": "2.0.0",
"1.0.0-patch": "2.0.0",
"1.0.0+build123": "2.0.0",
"1.0.0+build123.foo": "2.0.0",
"1.0.12": "2.0.0",
} {
tv, err := version.NewVersion(k)
checkFatal(t, err)
nv, err := majorBumper.bump(tv)
checkFatal(t, err)
if nv.String() != v {
t.Fatalf("Expected '%s' got '%s'", v, nv.String())
}
}
}