-
Notifications
You must be signed in to change notification settings - Fork 1
/
version_test.go
59 lines (51 loc) · 1.47 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
package main
import "testing"
func TestCheckVersionIsHigher(t *testing.T) {
versionFileName = "fixtures/0.0.1"
Version = "0.0.2"
if err := checkVersion(); err != nil {
t.Errorf("Received an unexpected error %s", err)
}
}
func TestCheckVersionIsLower(t *testing.T) {
versionFileName = "fixtures/0.0.2"
Version = "0.0.1"
if err := checkVersion(); err == nil {
t.Error("Received no error", err)
}
}
func TestCheckVersionIsTheSameWithBuildTag(t *testing.T) {
versionFileName = "fixtures/0.0.2"
Version = "0.0.2+envato"
if err := checkVersion(); err != nil {
t.Errorf("Received an unexpected error %s", err)
}
}
func TestCheckVersionIsLowerWithBuildTag(t *testing.T) {
versionFileName = "fixtures/0.0.2"
Version = "0.0.1+envato"
if err := checkVersion(); err == nil {
t.Error("Received no error", err)
}
}
func TestCheckVersionIsTheSameWithMatchingBuildTag(t *testing.T) {
versionFileName = "fixtures/0.0.2.buildtag"
Version = "0.0.2+buildtag"
if err := checkVersion(); err != nil {
t.Errorf("Received an unexpected error %s", err)
}
}
func TestCheckVersionIsTheSameWithoutMatchingBuildTag(t *testing.T) {
versionFileName = "fixtures/0.0.2.buildtag"
Version = "0.0.2+notbuildtag"
if err := checkVersion(); err == nil {
t.Error("Received no error", err)
}
}
func TestCheckVersionWithPreRelease(t *testing.T) {
versionFileName = "fixtures/0.0.2"
Version = "0.0.2-dirty"
if err := checkVersion(); err != nil {
t.Errorf("Received an unexpected error %s", err)
}
}