MCPcopy Create free account
hub / github.com/rabbitstack/fibratus / TestValidate

Function TestValidate

pkg/config/validation_test.go:26–92  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

24)
25
26func TestValidate(t *testing.T) {
27 var tests = []struct {
28 text string
29 valid bool
30 errs int
31 }{
32 {text: `aggregator:
33 flush-period: 20ms
34 flush-timeout: 1s`, valid: true},
35 {text: `aggregator:
36 flush-period: 20
37 flush-timeout: 1s`, valid: false, errs: 1},
38 {text: `aggregator:
39 flush-perio: 20ms
40 flush-timeout: 1`, valid: false, errs: 2},
41
42 {text: `alertsenders:
43 mail:
44 enabled: true
45 host: smtp.gmail.com
46 port: 465
47 user: user
48 password: pas$
49 from: from@mail.com
50 to:
51 - to@mail.com
52 slack:
53 enabled: true
54 url: https://slack.url
55 workspace: fibratus
56 channel: fibratus
57 emoji: ""`, valid: true},
58 {text: `alertsenders:
59 mail:
60 enabled: true
61 host: smtp.gmail.com
62 port:
63 user: user
64 pass: pas$
65 from: from@mail.com
66 to:
67 - invalidmail@
68 slack:
69 enabled: true
70 url: https://slack.url
71 workspace: fibratus
72 channel: fibratus
73 emoji: ""`, valid: false, errs: 6},
74 {text: `api:
75 transport: ""
76 timeout: 1s`, valid: false, errs: 1},
77 }
78
79 for i, tt := range tests {
80 var m interface{}
81 err := yaml.Unmarshal([]byte(tt.text), &m)
82 if err != nil {
83 t.Fatal(err)

Callers

nothing calls this directly

Calls 2

validateFunction · 0.70
UnmarshalMethod · 0.45

Tested by

no test coverage detected