-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain_test.go
135 lines (127 loc) · 2.54 KB
/
main_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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
package main
import (
"github.com/astralkn/gotestsum/pkg/operator"
"github.com/astralkn/gotestsum/pkg/options"
"os"
"testing"
)
func TestMain(m *testing.M) {
os.Exit(m.Run())
}
func TestTestFailError_Error(t1 *testing.T) {
type fields struct {
message string
}
tests := []struct {
name string
fields fields
want string
}{
{"expect message", fields{message: "test"}, "test"},
}
for _, tt := range tests {
t1.Run(tt.name, func(t1 *testing.T) {
t := &TestFailError{
message: tt.fields.message,
}
if got := t.Error(); got != tt.want {
t1.Errorf("Error() = %v, want %v", got, tt.want)
}
})
}
}
func Test_contains(t *testing.T) {
type args struct {
s []*operator.FailedTest
e *operator.FailedTest
}
tests := []struct {
name string
args args
want bool
}{
{"contains", args{
s: []*operator.FailedTest{{
Title: "test",
Issues: "made up",
},
},
e: &operator.FailedTest{
Title: "test",
Issues: "made up",
},
}, true}, {"not_contains", args{
s: []*operator.FailedTest{{
Title: "test",
Issues: "made up",
IssueNo: 0},
},
e: &operator.FailedTest{
Title: "test2",
Issues: "",
IssueNo: 0},
}, false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := contains(tt.args.s, tt.args.e); got != tt.want {
t.Errorf("contains() = %v, want %v", got, tt.want)
}
})
}
}
func Test_lookEnvWithDefault(t *testing.T) {
type args struct {
key string
defValue string
}
tests := []struct {
name string
args args
want string
}{
{"test_env_var", args{
key: "test",
defValue: "test",
}, "test"},
{
"empty_env_var", args{
key: "test",
defValue: "",
}, ""},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := lookEnvWithDefault(tt.args.key, tt.args.defValue); got != tt.want {
t.Errorf("lookEnvWithDefault() = %v, want %v", got, tt.want)
}
})
}
}
func Test_run(t *testing.T) {
type args struct {
opts *options.Options
}
tests := []struct {
name string
args args
wantErr bool
}{
{"unauth", args{&options.Options{
JunitFile: "test.xml",
Owner: "astralkn",
Repo: "test-bot-playground",
GitUnAuth: true,
}}, false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := run(tt.args.opts); (err != nil) != tt.wantErr {
t.Errorf("run() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}
//func TestFailExample(t *testing.T) {
// t.Fatal("This test fails on purpose")
//}