-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparallelenv_test.go
56 lines (51 loc) · 1.19 KB
/
parallelenv_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 parallelenv
import (
"testing"
"github.com/gostaticanalysis/testutil"
"golang.org/x/tools/go/analysis/analysistest"
)
// TestAnalyzer is a test for Analyzer.
func TestAnalyzer(t *testing.T) {
testdata := testutil.WithModules(t, analysistest.TestData(), nil)
analysistest.Run(t, testdata, Analyzer, "a")
}
func Test_target_isValid(t *testing.T) {
t.Parallel()
isValid, isNotValid := true, false
tests := map[string]struct {
tr target
want bool
}{
"valid value": {tSetEnv, isValid},
"unknown value": {unknown, isNotValid},
"out of range value": {-1, isNotValid},
}
for name, tt := range tests {
tt := tt
t.Run(name, func(t *testing.T) {
t.Parallel()
if got := tt.tr.isValid(); got != tt.want {
t.Errorf("target.isValid() = %v, want %v", got, tt.want)
}
})
}
}
func Test_sToTarget(t *testing.T) {
t.Parallel()
tests := map[string]struct {
s string
want target
}{
"success": {"t.Setenv", tSetEnv},
"failed": {"t.Short", unknown},
}
for name, tt := range tests {
tt := tt
t.Run(name, func(t *testing.T) {
t.Parallel()
if got := sToTarget(tt.s); got != tt.want {
t.Errorf("sToTarget() = %v, want %v", got, tt.want)
}
})
}
}