diff options
author | 2017-08-13 18:16:25 +0100 | |
---|---|---|
committer | 2017-08-13 18:16:25 +0100 | |
commit | 818d2b10adc6e69b2f94a50a56ac292a12278861 (patch) | |
tree | 7badfb8e0398dfb62f6d58b4ff9eb91b8a534b70 /middleware/autopath/setup_test.go | |
parent | 0c02708d63f62d6bca55effedd9601908311baa9 (diff) | |
download | coredns-818d2b10adc6e69b2f94a50a56ac292a12278861.tar.gz coredns-818d2b10adc6e69b2f94a50a56ac292a12278861.tar.zst coredns-818d2b10adc6e69b2f94a50a56ac292a12278861.zip |
cidr everywhere: check all middleware (#915)
* cidr everywhere: check all middleware
Add tests for cidr in only that middleware that already tests for this.
Check the other ones manually (and put reverse in the tests cases
anyway).
Make etcd setup_test run without +build etcd tag - it is not needed
for this test - move rest of the code to lookup_test.go.
Cleanup proxy test a bit and remove TempDir as there is test.TempFile
that does the same thing.
Fixes #909
* coredns package
* Fix test compile
Diffstat (limited to 'middleware/autopath/setup_test.go')
-rw-r--r-- | middleware/autopath/setup_test.go | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/middleware/autopath/setup_test.go b/middleware/autopath/setup_test.go index 0696a9179..b31110ddb 100644 --- a/middleware/autopath/setup_test.go +++ b/middleware/autopath/setup_test.go @@ -21,21 +21,18 @@ func TestSetupAutoPath(t *testing.T) { tests := []struct { input string shouldErr bool + expectedZone string expectedMw string // expected middleware. expectedSearch []string // expected search path expectedErrContent string // substring from the expected error. Empty for positive cases. }{ // positive - { - `autopath @kubernetes`, false, "kubernetes", nil, "", - }, - { - `autopath ` + resolv, false, "", []string{"bar.com.", "baz.com.", ""}, "", - }, + {`autopath @kubernetes`, false, "", "kubernetes", nil, ""}, + {`autopath example.org @kubernetes`, false, "example.org.", "kubernetes", nil, ""}, + {`autopath 10.0.0.0/8 @kubernetes`, false, "10.in-addr.arpa.", "kubernetes", nil, ""}, + {`autopath ` + resolv, false, "", "", []string{"bar.com.", "baz.com.", ""}, ""}, // negative - { - `autopath kubernetes`, true, "", nil, "open kubernetes: no such file or directory", - }, + {`autopath kubernetes`, true, "", "", nil, "open kubernetes: no such file or directory"}, } for i, test := range tests { @@ -64,6 +61,11 @@ func TestSetupAutoPath(t *testing.T) { t.Errorf("Test %d, wrong searchpath for input %s. Expected: '%v', actual: '%v'", i, test.input, test.expectedSearch, ap.search) } } + if !test.shouldErr && test.expectedZone != "" { + if test.expectedZone != ap.Zones[0] { + t.Errorf("Test %d, expected zone %q for input %s, got: %q", i, test.expectedZone, test.input, ap.Zones[0]) + } + } } } |