-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusetesting_test.go
66 lines (53 loc) · 1.99 KB
/
usetesting_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
package usetesting
import (
"testing"
"golang.org/x/tools/go/analysis/analysistest"
)
func TestAnalyzer(t *testing.T) {
testCases := []struct {
dir string
options map[string]string
}{
{dir: "oschdir/basic"},
{dir: "oschdir/dot"},
{dir: "oschdir/nottestfiles"},
{dir: "oschdir/disable", options: map[string]string{"oschdir": "false"}},
{dir: "contextbackground/basic"},
{dir: "contextbackground/dot"},
{dir: "contextbackground/nottestfiles"},
{dir: "contextbackground/disable", options: map[string]string{"contextbackground": "false"}},
{dir: "contexttodo/basic"},
{dir: "contexttodo/dot"},
{dir: "contexttodo/nottestfiles"},
{dir: "contexttodo/disable", options: map[string]string{"contexttodo": "false"}},
{dir: "osmkdirtemp/basic"},
{dir: "osmkdirtemp/dot"},
{dir: "osmkdirtemp/nottestfiles"},
{dir: "osmkdirtemp/disable", options: map[string]string{"osmkdirtemp": "false"}},
{dir: "ossetenv/basic", options: map[string]string{"ossetenv": "true"}},
{dir: "ossetenv/dot", options: map[string]string{"ossetenv": "true"}},
{dir: "ossetenv/nottestfiles", options: map[string]string{"ossetenv": "true"}},
{dir: "ossetenv/disable", options: map[string]string{"ossetenv": "false"}},
{dir: "ostempdir/basic", options: map[string]string{"ostempdir": "true"}},
{dir: "ostempdir/dot", options: map[string]string{"ostempdir": "true"}},
{dir: "ostempdir/nottestfiles", options: map[string]string{"ostempdir": "true"}},
{dir: "ostempdir/disable"},
{dir: "oscreatetemp/basic"},
{dir: "oscreatetemp/dot"},
{dir: "oscreatetemp/nottestfiles"},
{dir: "oscreatetemp/disable", options: map[string]string{"oscreatetemp": "false"}},
}
for _, test := range testCases {
t.Run(test.dir, func(t *testing.T) {
t.Parallel()
newAnalyzer := NewAnalyzer()
for k, v := range test.options {
err := newAnalyzer.Flags.Set(k, v)
if err != nil {
t.Fatal(err)
}
}
analysistest.RunWithSuggestedFixes(t, analysistest.TestData(), newAnalyzer, test.dir)
})
}
}