-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanalyzer_test.go
52 lines (49 loc) · 1.08 KB
/
analyzer_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
package directive_test
import (
"fmt"
"os"
"testing"
"github.com/gqlgo/directive"
"github.com/gqlgo/gqlanalysis/analysistest"
)
func TestDirective(t *testing.T) {
type args struct {
analyzer string
}
tests := []struct {
name string
args args
}{
{
name: "constraint directive",
args: args{analyzer: "constraint"},
},
{
name: "id directive",
args: args{analyzer: "id"},
},
{
name: "list directive",
args: args{analyzer: "list"},
},
{
name: "permission directive",
args: args{analyzer: "permission"},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
testdata := analysistest.TestData(t)
configFilePath := fmt.Sprintf("./testdata/%s/directive.yaml", tt.args.analyzer)
configFile, err := os.Open(configFilePath)
if err != nil {
t.Fatalf("failed to open config file: %v", err)
}
config, err := directive.ParseConfigFile(configFile)
if err != nil {
t.Fatalf("failed to parse config file: %v", err)
}
analysistest.Run(t, testdata, directive.NewAnalyzers(config)[0], tt.args.analyzer)
})
}
}