-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathspancheck_test.go
49 lines (41 loc) · 1.18 KB
/
spancheck_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
package spancheck_test
import (
"testing"
"golang.org/x/tools/go/analysis/analysistest"
"github.com/jjti/go-spancheck"
)
func Test(t *testing.T) {
t.Parallel()
type configFactory func() *spancheck.Config
for dir, configFactory := range map[string]configFactory{
"base": spancheck.NewDefaultConfig,
"disableerrorchecks": func() *spancheck.Config {
cfg := spancheck.NewDefaultConfig()
cfg.EnabledChecks = []string{
spancheck.EndCheck.String(),
spancheck.RecordErrorCheck.String(),
spancheck.SetStatusCheck.String(),
}
cfg.IgnoreChecksSignaturesSlice = []string{"telemetry.Record", "recordErr"}
return cfg
},
"enableall": func() *spancheck.Config {
cfg := spancheck.NewDefaultConfig()
cfg.EnabledChecks = []string{
spancheck.EndCheck.String(),
spancheck.RecordErrorCheck.String(),
spancheck.SetStatusCheck.String(),
}
cfg.StartSpanMatchersSlice = append(cfg.StartSpanMatchersSlice,
"util.TestStartTrace:opentelemetry",
"enableall.testStartTrace:opencensus",
)
return cfg
},
} {
dir := dir
t.Run(dir, func(t *testing.T) {
analysistest.Run(t, "testdata/"+dir, spancheck.NewAnalyzerWithConfig(configFactory()))
})
}
}