-
Notifications
You must be signed in to change notification settings - Fork 7
/
setup_test.go
43 lines (38 loc) · 947 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
40
41
42
43
package records
import (
"testing"
"github.com/coredns/caddy"
)
func TestRecordsParse(t *testing.T) {
tests := []struct {
input string
shouldErr bool
expectedOrigins []string
}{
{
`records {
@ IN MX 10 mx1.example.org.
}
`,
false, []string{"."},
},
}
for i, test := range tests {
c := caddy.NewTestController("dns", test.input)
re, err := recordsParse(c)
if err == nil && test.shouldErr {
t.Fatalf("Test %d expected errors, but got no error", i)
} else if err != nil && !test.shouldErr {
t.Fatalf("Test %d expected no errors, but got '%v'", i, err)
} else {
if len(re.origins) != len(test.expectedOrigins) {
t.Fatalf("Test %d expected %v, got %v", i, test.expectedOrigins, re.origins)
}
for j, name := range test.expectedOrigins {
if re.origins[j] != name {
t.Fatalf("Test %d expected %v for %d th zone, got %v", i, name, j, re.origins[j])
}
}
}
}
}