-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp_test.go
112 lines (109 loc) · 1.83 KB
/
app_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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
package vin
import "testing"
func TestApp_parseOwnerAndRepo(t *testing.T) {
type args struct {
s string
}
tests := []struct {
name string
args args
want string
want1 string
wantErr bool
}{
{
name: "",
args: args{
s: "abc",
},
want: "",
want1: "",
wantErr: true,
},
{
name: "",
args: args{
s: "abc/def",
},
want: "abc",
want1: "def",
wantErr: false,
},
{
name: "",
args: args{
s: "abc/def/ghi",
},
want: "",
want1: "",
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
a := &App{}
got, got1, err := a.parseOwnerAndRepo(tt.args.s)
if (err != nil) != tt.wantErr {
t.Errorf("App.parseOwnerAndRepo() error = %v, wantErr %v", err, tt.wantErr)
return
}
if got != tt.want {
t.Errorf("App.parseOwnerAndRepo() got = %v, want %v", got, tt.want)
}
if got1 != tt.want1 {
t.Errorf("App.parseOwnerAndRepo() got1 = %v, want %v", got1, tt.want1)
}
})
}
}
func Test_contains(t *testing.T) {
type args struct {
s string
substrs []string
}
tests := []struct {
name string
args args
want bool
}{
{
name: "",
args: args{
s: "abc def",
substrs: []string{"abc"},
},
want: true,
},
{
name: "",
args: args{
s: "abc def",
substrs: []string{"abc", "def"},
},
want: true,
},
{
name: "",
args: args{
s: "abc def",
substrs: []string{"def", "efg"},
},
want: false,
},
{
name: "",
args: args{
s: "abc def",
substrs: []string{"efg", "hij"},
},
want: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := contains(tt.args.s, tt.args.substrs); got != tt.want {
t.Errorf("contains() = %v, want %v", got, tt.want)
}
})
}
}