diff options
author | 2018-02-28 08:43:19 -0800 | |
---|---|---|
committer | 2018-02-28 08:43:19 -0800 | |
commit | 928de738dd70e7074cdd563d2247305fe1fcad35 (patch) | |
tree | 4a6789f3312e6355b34fa81881b0e6187aab3459 /plugin/pkg/dnsutil/reverse_test.go | |
parent | 395b614349ad730af8edbae204a4744128e0b0f3 (diff) | |
download | coredns-928de738dd70e7074cdd563d2247305fe1fcad35.tar.gz coredns-928de738dd70e7074cdd563d2247305fe1fcad35.tar.zst coredns-928de738dd70e7074cdd563d2247305fe1fcad35.zip |
Rename reverse zone constants (#1568)
Rename the constants to IP4arpa and IP6arpa (shorter and exported) and
make IsReverse return the type of the reverse zone which could be handy
for some callers.
Also add tests for IsReverse()
Diffstat (limited to 'plugin/pkg/dnsutil/reverse_test.go')
-rw-r--r-- | plugin/pkg/dnsutil/reverse_test.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/plugin/pkg/dnsutil/reverse_test.go b/plugin/pkg/dnsutil/reverse_test.go index 25bd897ac..3cf2f0c51 100644 --- a/plugin/pkg/dnsutil/reverse_test.go +++ b/plugin/pkg/dnsutil/reverse_test.go @@ -49,3 +49,23 @@ func TestExtractAddressFromReverse(t *testing.T) { } } } + +func TestIsReverse(t *testing.T) { + tests := []struct { + name string + expected int + }{ + {"b.a.9.8.7.6.5.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.", 2}, + {"d.0.1.0.0.2.in-addr.arpa.", 1}, + {"example.com.", 0}, + {"", 0}, + {"in-addr.arpa.example.com.", 0}, + } + for i, tc := range tests { + got := IsReverse(tc.name) + if got != tc.expected { + t.Errorf("Test %d, got %d, expected %d for %s", i, got, tc.expected, tc.name) + } + + } +} |