aboutsummaryrefslogtreecommitdiff
path: root/middleware/secondary/setup_test.go
blob: c58483f6bc6b67badb1ff74e78565a334ac95c4a (plain) (blame)
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
package secondary

import (
	"testing"

	"github.com/mholt/caddy"
)

// TODO(miek): this only check the syntax.
func TestSecondaryParse(t *testing.T) {
	tests := []struct {
		inputFileRules string
		shouldErr      bool
		transferFrom   string
	}{
		{
			`secondary`,
			false, // TODO(miek): should actually be true, because without transfer lines this does not make sense
			"",
		},
		{
			`secondary {
				transfer from 127.0.0.1
				transfer to 127.0.0.1
			}`,
			false,
			"",
		},
	}

	for i, test := range tests {
		c := caddy.NewTestController("dns", test.inputFileRules)
		_, err := secondaryParse(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)
		}
	}
}