-
Notifications
You must be signed in to change notification settings - Fork 8
/
utils_test.go
56 lines (33 loc) · 1.01 KB
/
utils_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
package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestComapreVersion_NextIsNew_Patch(t *testing.T) {
isUpdate := compareVersion("0.0.1", "0.0.2")
assert.Equal(t, 1, isUpdate)
}
func TestComapreVersion_NextIsNew_Minor(t *testing.T) {
isUpdate := compareVersion("0.0.1", "0.2.1")
assert.Equal(t, 1, isUpdate)
}
func TestComapreVersion_NextIsNew_Major(t *testing.T) {
isUpdate := compareVersion("0.0.1", "1.0.2")
assert.Equal(t, 1, isUpdate)
}
func TestComapreVersion_CurrIsNew_Patch(t *testing.T) {
isUpdate := compareVersion("0.0.12", "0.0.2")
assert.Equal(t, -1, isUpdate)
}
func TestComapreVersion_CurrIsNew_Minor(t *testing.T) {
isUpdate := compareVersion("0.10.1", "0.2.1")
assert.Equal(t, -1, isUpdate)
}
func TestComapreVersion_CurrIsNew_Major(t *testing.T) {
isUpdate := compareVersion("10.0.1", "1.0.2")
assert.Equal(t, -1, isUpdate)
}
func TestComapreVersion_BothAreSame(t *testing.T) {
isUpdate := compareVersion("10.0.1", "10.0.1")
assert.Equal(t, 0, isUpdate)
}