-
Notifications
You must be signed in to change notification settings - Fork 6
/
errchkjson_test.go
48 lines (39 loc) · 1.35 KB
/
errchkjson_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
package errchkjson_test
import (
"testing"
"golang.org/x/tools/go/analysis/analysistest"
"github.com/breml/errchkjson"
)
// Because of the global nature of the analyzers flags, the order of the test cases needs to be maintained.
// Otherwise flags from previous tests could affect subsequent tests.
func TestDefault(t *testing.T) {
testdata := analysistest.TestData()
analysistest.Run(t, testdata, errchkjson.NewAnalyzer(), "standard")
}
func TestOmitSafeFlag(t *testing.T) {
errchkjson := errchkjson.NewAnalyzer()
err := errchkjson.Flags.Set("omit-safe", "true")
if err != nil {
t.Fatalf("error setting 'omit-safe' command line flag: %v", err)
}
testdata := analysistest.TestData()
analysistest.Run(t, testdata, errchkjson, "nosafe")
}
func TestNoExportedField(t *testing.T) {
errchkjson := errchkjson.NewAnalyzer()
err := errchkjson.Flags.Set("omit-safe", "true")
if err != nil {
t.Fatalf("error setting 'omit-safe' command line flag: %v", err)
}
err = errchkjson.Flags.Set("report-no-exported", "true")
if err != nil {
t.Fatalf("error setting 'report-no-exported' command line flag: %v", err)
}
testdata := analysistest.TestData()
analysistest.Run(t, testdata, errchkjson, "noexport")
}
func TestLoop(t *testing.T) {
errchkjson := errchkjson.NewAnalyzer()
testdata := analysistest.TestData()
analysistest.Run(t, testdata, errchkjson, "loop")
}