-
Notifications
You must be signed in to change notification settings - Fork 4
/
setup_test.go
39 lines (31 loc) · 990 Bytes
/
setup_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
//go:build !codeanalysis
// +build !codeanalysis
package finalize
import (
"testing"
"github.com/coredns/caddy"
)
// TestSetup tests the various things that should be parsed by setup.
// Make sure you also test for parse errors.
func TestSetup(t *testing.T) {
c := caddy.NewTestController("dns", `finalize`)
if err := setup(c); err != nil {
t.Fatalf("Expected no errors, but got: %v", err)
}
c = caddy.NewTestController("dns", `finalize max_depth`)
if err := setup(c); err == nil {
t.Fatalf("Expected errors, but got: %v", err)
}
c = caddy.NewTestController("dns", `finalize max_depth 0`)
if err := setup(c); err == nil {
t.Fatalf("Expected errors, but got: %v", err)
}
c = caddy.NewTestController("dns", `finalize max_depth x`)
if err := setup(c); err == nil {
t.Fatalf("Expected errors, but got: %v", err)
}
c = caddy.NewTestController("dns", `finalize max_depth 1`)
if err := setup(c); err != nil {
t.Fatalf("Expected no errors, but got: %v", err)
}
}