/
version_test.go
81 lines (67 loc) · 1.38 KB
/
version_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
79
80
81
package version_test
import (
"testing"
)
import (
"github.com/chuckpreslar/version"
)
func TestMajorVersion(t *testing.T) {
var (
ver = version.Establish(1, 0, 0)
act = ver.Major()
exp = 1
)
if exp != act {
t.Errorf("expected value of major version to be %d, got %d", exp, act)
}
}
func TestMinorVersion(t *testing.T) {
var (
ver = version.Establish(0, 1, 0)
act = ver.Minor()
exp = 1
)
if exp != act {
t.Errorf("expected value of minor version to be %d, got %d", exp, act)
}
}
func TestPatchVersion(t *testing.T) {
var (
ver = version.Establish(0, 0, 1)
act = ver.Patch()
exp = 1
)
if exp != act {
t.Errorf("expected value of patch version to be %d, got %d", exp, act)
}
}
func TestLabelVersion(t *testing.T) {
var (
ver = version.Establish(0, 0, 1, "rc1")
act = ver.Label()
exp = "rc1"
)
if exp != act {
t.Errorf("expected value of label version to be %s, got %s", exp, act)
}
}
func TestVersionStringWithLabel(t *testing.T) {
var (
ver = version.Establish(1, 0, 0, "rc1")
act = ver.String()
exp = "1.0.0-rc1"
)
if exp != act {
t.Errorf("expected string value of version to be %s, got %s", exp, act)
}
}
func TestVersionStringWithoutLabel(t *testing.T) {
var (
ver = version.Establish(1, 0, 0)
act = ver.String()
exp = "1.0.0"
)
if exp != act {
t.Errorf("expected string value of version to be %s, got %s", exp, act)
}
}