This repository has been archived by the owner on Jul 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
version_test.go
95 lines (91 loc) · 1.65 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package vrcarjt
import (
"reflect"
"testing"
)
func Test_getVersion(t *testing.T) {
type args struct {
version string
}
tests := []struct {
name string
args args
want *Version
wantErr bool
}{
{
name: "Should return a valid Version for v2.7.0",
args: args{
"v2.7.0",
},
want: &Version{
Major: 2,
Minor: 7,
Patch: 0,
},
wantErr: false,
},
{
name: "Should return a valid Version for v2.7.1",
args: args{
"v2.7.1",
},
want: &Version{
Major: 2,
Minor: 7,
Patch: 1,
},
wantErr: false,
},
{
name: "Should fail for an invalid version type for 2.7.1",
args: args{
"2.7.1",
},
want: nil,
wantErr: true,
},
{
name: "Should fail for an empty string",
args: args{
"",
},
want: nil,
wantErr: true,
},
{
name: "Should return a valid version type for 2.7.1-beta",
args: args{
"v2.7.1-beta",
},
want: &Version{
Major: 2,
Minor: 7,
Patch: 1,
Beta: true,
},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := getVersion(tt.args.version)
if (err != nil) != tt.wantErr {
t.Errorf("getVersion() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("getVersion() = %v, want %v", got, tt.want)
}
})
}
}
func TestVRCAutoRejoinTool_GetCurrentVersion(t *testing.T) {
t.Run("Should return a valid version", func(t *testing.T) {
v := NewVRCAutoRejoinTool()
_, err := v.GetCurrentVersion()
if err != nil {
t.Errorf("VRCAutoRejoinTool.GetCurrentVersion() error = %v", err)
}
})
}