-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplum_test.go
56 lines (48 loc) · 1.08 KB
/
plum_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 goplum_test
import (
"fmt"
"path"
"testing"
"github.com/csmith/goplum"
"github.com/csmith/goplum/plugins/debug"
"github.com/csmith/goplum/plugins/http"
"github.com/sebdah/goldie/v2"
)
var plugins = map[string]goplum.PluginLoader{
"http": func() (goplum.Plugin, error) {
return http.Plugin{}, nil
},
"debug": func() (goplum.Plugin, error) {
return debug.Plugin{}, nil
},
}
func TestReadConfig_GoldenData(t *testing.T) {
tests := []string{
"defaults",
"duplicate-alert",
"duplicate-check",
"unknown-alert",
"unknown-check",
"unknown-field",
"unknown-plugin",
"unrecognised-alert-multiple",
"unrecognised-alert-single",
"unrecognised-alert-wildcard",
"validation-error",
}
gold := goldie.New(t)
for i := range tests {
t.Run(tests[i], func(t *testing.T) {
plum := goplum.NewPlum()
plum.RegisterPlugins(plugins)
err := plum.ReadConfig(path.Join("testdata", fmt.Sprintf("%s.conf", tests[i])))
var actual interface{}
if err == nil {
actual = plum
} else {
actual = err.Error()
}
gold.AssertJson(t, tests[i], actual)
})
}
}