-
Notifications
You must be signed in to change notification settings - Fork 1
/
config_test.go
45 lines (42 loc) · 896 Bytes
/
config_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
package spancheck
import (
"strings"
"testing"
)
func Test_parseChecks(t *testing.T) {
t.Parallel()
for flag, tc := range map[string]struct {
checks []Check
}{
"": {
checks: []Check{},
},
"unknown": {
checks: []Check{},
},
"end": {
checks: []Check{EndCheck},
},
"end,record-error": {
checks: []Check{EndCheck, RecordErrorCheck},
},
"end,record-error,set-status": {
checks: []Check{EndCheck, RecordErrorCheck, SetStatusCheck},
},
} {
flag, tc := flag, tc
t.Run(flag, func(t *testing.T) {
t.Parallel()
checks := parseChecks(strings.Split(flag, ","))
if len(checks) != len(tc.checks) {
t.Fatalf("Unexpected checks length=%d, want=%d", len(checks), len(tc.checks))
}
for i, check := range tc.checks {
want := tc.checks[i]
if check != want {
t.Fatalf("Unexpected check=%+v, want=%+v", check, want)
}
}
})
}
}