More tests

This commit is contained in:
Miek Gieben 2015-08-26 11:26:45 +01:00
parent aec78ad5e4
commit e1d5f172ae
2 changed files with 23 additions and 1 deletions

View File

@ -117,6 +117,8 @@ func normalizedString(r RR) (string, int) {
// needsDeletion checks if the RR is masked by either a CNAME or a DNAME.
// If so it return true.
func needsDeletion(r RR, s string, cname, dname []string) bool {
// TODO(miek): fix.
// This is too broad, but we have to be care full not to delete ourselves.
if r.Header().Rrtype == TypeCNAME || r.Header().Rrtype == TypeDNAME {
return false
}

View File

@ -66,11 +66,31 @@ func TestDedupWithCNAMEDNAME(t *testing.T) {
newRR(t, "miEk.nl. CNAME a."),
newRR(t, "mieK.nl. CNAME a."),
}: []string{"Miek.nl.\t3600\tIN\tCNAME\ta."},
[...]RR{
newRR(t, "miek.nl. CNAME a."),
newRR(t, "a.miek.nl. CNAME a."),
newRR(t, "a.miek.nl. CNAME a."),
newRR(t, "a.miek.nl. CNAME a."),
}: []string{"miek.nl.\t3600\tIN\tCNAME\ta.",
"a.miek.nl.\t3600\tIN\tCNAME\ta."},
[...]RR{
newRR(t, "miek.nl. DNAME a."),
newRR(t, "a.miek.nl. CNAME a."),
newRR(t, "b.miek.nl. IN A 127.0.0.1"),
newRR(t, "a.miek.de. IN A 127.0.0.1"),
}: []string{"miek.nl.\t3600\tIN\tDNAME\ta.",
"a.miek.de.\t3600\tIN\tA\t127.0.0.1"},
[...]RR{
newRR(t, "miek.nl. DNAME a."),
newRR(t, "a.miek.nl. DNAME a."),
newRR(t, "b.miek.nl. DNAME b."),
newRR(t, "a.b.miek.nl. DNAME a.b"),
}: []string{"miek.nl.\t3600\tIN\tDNAME\ta."},
}
T := 0
for rr, expected := range testcases {
out := Dedup([]RR{rr[0], rr[1], rr[2]})
out := Dedup([]RR{rr[0], rr[1], rr[2], rr[3]})
for i, o := range out {
if o.String() != expected[i] {
t.Fatalf("test %d, expected %v, got %v", T, expected[i], o.String())