From 928de738dd70e7074cdd563d2247305fe1fcad35 Mon Sep 17 00:00:00 2001 From: Miek Gieben Date: Wed, 28 Feb 2018 08:43:19 -0800 Subject: 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() --- plugin/pkg/dnsutil/reverse_test.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'plugin/pkg/dnsutil/reverse_test.go') 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) + } + + } +} -- cgit v1.2.3