tests: add SortAndCheck helper (#926)

There was quite some code duplication in a lot of tests to check if
an answer was considered Ok. Created a test.SortAndCheck helper function
that takes care of this.
This commit is contained in:
Miek Gieben 2017-08-16 15:30:58 +01:00 committed by GitHub
parent 65b56248f0
commit 7f46df6d27
24 changed files with 58 additions and 520 deletions

View file

@ -56,6 +56,8 @@ func TestAutoPath(t *testing.T) {
continue
}
// No sorting here as we want to check if the CNAME sits *before* the
// test of the answer.
resp := rec.Msg
if !test.Header(t, tc, resp) {

View file

@ -1,7 +1,6 @@
package dnssec
import (
"sort"
"strings"
"testing"
@ -104,23 +103,7 @@ func TestLookupZone(t *testing.T) {
}
resp := rec.Msg
sort.Sort(test.RRSet(resp.Answer))
sort.Sort(test.RRSet(resp.Ns))
sort.Sort(test.RRSet(resp.Extra))
if !test.Header(t, tc, resp) {
t.Logf("%v\n", resp)
continue
}
if !test.Section(t, tc, test.Answer, resp.Answer) {
t.Logf("%v\n", resp)
}
if !test.Section(t, tc, test.Ns, resp.Ns) {
t.Logf("%v\n", resp)
}
if !test.Section(t, tc, test.Extra, resp.Extra) {
t.Logf("%v\n", resp)
}
test.SortAndCheck(t, resp, tc)
}
}
@ -147,23 +130,7 @@ func TestLookupDNSKEY(t *testing.T) {
t.Errorf("Authoritative Answer should be true, got false")
}
sort.Sort(test.RRSet(resp.Answer))
sort.Sort(test.RRSet(resp.Ns))
sort.Sort(test.RRSet(resp.Extra))
if !test.Header(t, tc, resp) {
t.Logf("%v\n", resp)
continue
}
if !test.Section(t, tc, test.Answer, resp.Answer) {
t.Logf("%v\n", resp)
}
if !test.Section(t, tc, test.Ns, resp.Ns) {
t.Logf("%v\n", resp)
}
if !test.Section(t, tc, test.Extra, resp.Extra) {
t.Logf("%v\n", resp)
}
test.SortAndCheck(t, resp, tc)
}
}

View file

@ -3,7 +3,6 @@
package etcd
import (
"sort"
"testing"
"github.com/coredns/coredns/middleware/etcd/msg"
@ -29,23 +28,7 @@ func TestDebugLookup(t *testing.T) {
etc.ServeDNS(ctxt, rec, m)
resp := rec.Msg
sort.Sort(test.RRSet(resp.Answer))
sort.Sort(test.RRSet(resp.Ns))
sort.Sort(test.RRSet(resp.Extra))
if !test.Header(t, tc, resp) {
t.Logf("%v\n", resp)
continue
}
if !test.Section(t, tc, test.Answer, resp.Answer) {
t.Logf("%v\n", resp)
}
if !test.Section(t, tc, test.Ns, resp.Ns) {
t.Logf("%v\n", resp)
}
if !test.Section(t, tc, test.Extra, resp.Extra) {
t.Logf("%v\n", resp)
}
test.SortAndCheck(t, resp, tc)
}
}
@ -63,23 +46,7 @@ func TestDebugLookupFalse(t *testing.T) {
etc.ServeDNS(ctxt, rec, m)
resp := rec.Msg
sort.Sort(test.RRSet(resp.Answer))
sort.Sort(test.RRSet(resp.Ns))
sort.Sort(test.RRSet(resp.Extra))
if !test.Header(t, tc, resp) {
t.Logf("%v\n", resp)
continue
}
if !test.Section(t, tc, test.Answer, resp.Answer) {
t.Logf("%v\n", resp)
}
if !test.Section(t, tc, test.Ns, resp.Ns) {
t.Logf("%v\n", resp)
}
if !test.Section(t, tc, test.Extra, resp.Extra) {
t.Logf("%v\n", resp)
}
test.SortAndCheck(t, resp, tc)
}
}

View file

@ -3,7 +3,6 @@
package etcd
import (
"sort"
"testing"
"github.com/coredns/coredns/middleware/etcd/msg"
@ -31,23 +30,7 @@ func TestGroupLookup(t *testing.T) {
}
resp := rec.Msg
sort.Sort(test.RRSet(resp.Answer))
sort.Sort(test.RRSet(resp.Ns))
sort.Sort(test.RRSet(resp.Extra))
if !test.Header(t, tc, resp) {
t.Logf("%v\n", resp)
continue
}
if !test.Section(t, tc, test.Answer, resp.Answer) {
t.Logf("%v\n", resp)
}
if !test.Section(t, tc, test.Ns, resp.Ns) {
t.Logf("%v\n", resp)
}
if !test.Section(t, tc, test.Extra, resp.Extra) {
t.Logf("%v\n", resp)
}
test.SortAndCheck(t, resp, tc)
}
}

View file

@ -5,7 +5,6 @@ package etcd
import (
"context"
"encoding/json"
"sort"
"testing"
"time"
@ -267,23 +266,7 @@ func TestLookup(t *testing.T) {
etc.ServeDNS(ctxt, rec, m)
resp := rec.Msg
sort.Sort(test.RRSet(resp.Answer))
sort.Sort(test.RRSet(resp.Ns))
sort.Sort(test.RRSet(resp.Extra))
if !test.Header(t, tc, resp) {
t.Logf("%v\n", resp)
continue
}
if !test.Section(t, tc, test.Answer, resp.Answer) {
t.Logf("%v\n", resp)
}
if !test.Section(t, tc, test.Ns, resp.Ns) {
t.Logf("%v\n", resp)
}
if !test.Section(t, tc, test.Extra, resp.Extra) {
t.Logf("%v\n", resp)
}
test.SortAndCheck(t, resp, tc)
}
}

View file

@ -3,7 +3,6 @@
package etcd
import (
"sort"
"testing"
"github.com/coredns/coredns/middleware/etcd/msg"
@ -34,23 +33,7 @@ func TestMultiLookup(t *testing.T) {
}
resp := rec.Msg
sort.Sort(test.RRSet(resp.Answer))
sort.Sort(test.RRSet(resp.Ns))
sort.Sort(test.RRSet(resp.Extra))
if !test.Header(t, tc, resp) {
t.Logf("%v\n", resp)
continue
}
if !test.Section(t, tc, test.Answer, resp.Answer) {
t.Logf("%v\n", resp)
}
if !test.Section(t, tc, test.Ns, resp.Ns) {
t.Logf("%v\n", resp)
}
if !test.Section(t, tc, test.Extra, resp.Extra) {
t.Logf("%v\n", resp)
}
test.SortAndCheck(t, resp, tc)
}
}

View file

@ -6,7 +6,6 @@ package etcd
import (
"fmt"
"sort"
"strings"
"testing"
@ -35,23 +34,7 @@ func TestOtherLookup(t *testing.T) {
}
resp := rec.Msg
sort.Sort(test.RRSet(resp.Answer))
sort.Sort(test.RRSet(resp.Ns))
sort.Sort(test.RRSet(resp.Extra))
if !test.Header(t, tc, resp) {
t.Logf("%v\n", resp)
continue
}
if !test.Section(t, tc, test.Answer, resp.Answer) {
t.Logf("%v\n", resp)
}
if !test.Section(t, tc, test.Ns, resp.Ns) {
t.Logf("%v\n", resp)
}
if !test.Section(t, tc, test.Extra, resp.Extra) {
t.Logf("%v\n", resp)
}
test.SortAndCheck(t, resp, tc)
}
}

View file

@ -3,7 +3,6 @@
package etcd
import (
"sort"
"testing"
"github.com/coredns/coredns/middleware/etcd/msg"
@ -35,23 +34,7 @@ func TestProxyLookupFailDebug(t *testing.T) {
}
resp := rec.Msg
sort.Sort(test.RRSet(resp.Answer))
sort.Sort(test.RRSet(resp.Ns))
sort.Sort(test.RRSet(resp.Extra))
if !test.Header(t, tc, resp) {
t.Logf("%v\n", resp)
continue
}
if !test.Section(t, tc, test.Answer, resp.Answer) {
t.Logf("%v\n", resp)
}
if !test.Section(t, tc, test.Ns, resp.Ns) {
t.Logf("%v\n", resp)
}
if !test.Section(t, tc, test.Extra, resp.Extra) {
t.Logf("%v\n", resp)
}
test.SortAndCheck(t, resp, tc)
}
}

View file

@ -4,7 +4,6 @@ package etcd
import (
"net"
"sort"
"strconv"
"testing"
@ -66,23 +65,8 @@ func TestStubLookup(t *testing.T) {
// etcd not running?
continue
}
sort.Sort(test.RRSet(resp.Answer))
sort.Sort(test.RRSet(resp.Ns))
sort.Sort(test.RRSet(resp.Extra))
if !test.Header(t, tc, resp) {
t.Logf("%v\n", resp)
continue
}
if !test.Section(t, tc, test.Answer, resp.Answer) {
t.Logf("%v\n", resp)
}
if !test.Section(t, tc, test.Ns, resp.Ns) {
t.Logf("%v\n", resp)
}
if !test.Section(t, tc, test.Extra, resp.Extra) {
t.Logf("%v\n", resp)
}
test.SortAndCheck(t, resp, tc)
}
}

View file

@ -1,7 +1,6 @@
package file
import (
"sort"
"strings"
"testing"
@ -34,25 +33,7 @@ func TestLookupCNAMEChain(t *testing.T) {
}
resp := rec.Msg
sort.Sort(test.RRSet(resp.Answer))
sort.Sort(test.RRSet(resp.Ns))
sort.Sort(test.RRSet(resp.Extra))
if !test.Header(t, tc, resp) {
t.Logf("%v\n", resp)
continue
}
if !test.Section(t, tc, test.Answer, resp.Answer) {
t.Logf("%v\n", resp)
}
if !test.Section(t, tc, test.Ns, resp.Ns) {
t.Logf("%v\n", resp)
}
if !test.Section(t, tc, test.Extra, resp.Extra) {
t.Logf("%v\n", resp)
}
test.SortAndCheck(t, resp, tc)
}
}
@ -109,25 +90,7 @@ func TestLookupCNAMEExternal(t *testing.T) {
}
resp := rec.Msg
sort.Sort(test.RRSet(resp.Answer))
sort.Sort(test.RRSet(resp.Ns))
sort.Sort(test.RRSet(resp.Extra))
if !test.Header(t, tc, resp) {
t.Logf("%v\n", resp)
continue
}
if !test.Section(t, tc, test.Answer, resp.Answer) {
t.Logf("%v\n", resp)
}
if !test.Section(t, tc, test.Ns, resp.Ns) {
t.Logf("%v\n", resp)
}
if !test.Section(t, tc, test.Extra, resp.Extra) {
t.Logf("%v\n", resp)
}
test.SortAndCheck(t, resp, tc)
}
}

View file

@ -1,7 +1,6 @@
package file
import (
"sort"
"strings"
"testing"
@ -171,23 +170,7 @@ func testDelegation(t *testing.T, z, origin string, testcases []test.Case) {
}
resp := rec.Msg
sort.Sort(test.RRSet(resp.Answer))
sort.Sort(test.RRSet(resp.Ns))
sort.Sort(test.RRSet(resp.Extra))
if !test.Header(t, tc, resp) {
t.Logf("%v\n", resp)
continue
}
if !test.Section(t, tc, test.Answer, resp.Answer) {
t.Logf("%v\n", resp)
}
if !test.Section(t, tc, test.Ns, resp.Ns) {
t.Logf("%v\n", resp)
}
if !test.Section(t, tc, test.Extra, resp.Extra) {
t.Logf("%v\n", resp)
}
test.SortAndCheck(t, resp, tc)
}
}

View file

@ -1,7 +1,6 @@
package file
import (
"sort"
"strings"
"testing"
@ -110,23 +109,7 @@ func TestLookupDNAME(t *testing.T) {
}
resp := rec.Msg
sort.Sort(test.RRSet(resp.Answer))
sort.Sort(test.RRSet(resp.Ns))
sort.Sort(test.RRSet(resp.Extra))
if !test.Header(t, tc, resp) {
t.Logf("%v\n", resp)
continue
}
if !test.Section(t, tc, test.Answer, resp.Answer) {
t.Logf("%v\n", resp)
}
if !test.Section(t, tc, test.Ns, resp.Ns) {
t.Logf("%v\n", resp)
}
if !test.Section(t, tc, test.Extra, resp.Extra) {
t.Logf("%v\n", resp)
}
test.SortAndCheck(t, resp, tc)
}
}
@ -179,23 +162,7 @@ func TestLookupDNAMEDNSSEC(t *testing.T) {
}
resp := rec.Msg
sort.Sort(test.RRSet(resp.Answer))
sort.Sort(test.RRSet(resp.Ns))
sort.Sort(test.RRSet(resp.Extra))
if !test.Header(t, tc, resp) {
t.Logf("%v\n", resp)
continue
}
if !test.Section(t, tc, test.Answer, resp.Answer) {
t.Logf("%v\n", resp)
}
if !test.Section(t, tc, test.Ns, resp.Ns) {
t.Logf("%v\n", resp)
}
if !test.Section(t, tc, test.Extra, resp.Extra) {
t.Logf("%v\n", resp)
}
test.SortAndCheck(t, resp, tc)
}
}

View file

@ -1,7 +1,6 @@
package file
import (
"sort"
"strings"
"testing"
@ -147,25 +146,7 @@ func TestLookupDNSSEC(t *testing.T) {
}
resp := rec.Msg
sort.Sort(test.RRSet(resp.Answer))
sort.Sort(test.RRSet(resp.Ns))
sort.Sort(test.RRSet(resp.Extra))
if !test.Header(t, tc, resp) {
t.Logf("%v\n", resp)
continue
}
if !test.Section(t, tc, test.Answer, resp.Answer) {
t.Logf("%v\n", resp)
}
if !test.Section(t, tc, test.Ns, resp.Ns) {
t.Logf("%v\n", resp)
}
if !test.Section(t, tc, test.Extra, resp.Extra) {
t.Logf("%v\n", resp)
}
test.SortAndCheck(t, resp, tc)
}
}

View file

@ -1,7 +1,6 @@
package file
import (
"sort"
"strings"
"testing"
@ -71,22 +70,6 @@ func TestLookupDS(t *testing.T) {
}
resp := rec.Msg
sort.Sort(test.RRSet(resp.Answer))
sort.Sort(test.RRSet(resp.Ns))
sort.Sort(test.RRSet(resp.Extra))
if !test.Header(t, tc, resp) {
t.Logf("%v\n", resp)
continue
}
if !test.Section(t, tc, test.Answer, resp.Answer) {
t.Logf("%v\n", resp)
}
if !test.Section(t, tc, test.Ns, resp.Ns) {
t.Logf("%v\n", resp)
}
if !test.Section(t, tc, test.Extra, resp.Extra) {
t.Logf("%v\n", resp)
}
test.SortAndCheck(t, resp, tc)
}
}

View file

@ -1,7 +1,6 @@
package file
import (
"sort"
"strings"
"testing"
@ -51,25 +50,7 @@ func TestLookupEnt(t *testing.T) {
}
resp := rec.Msg
sort.Sort(test.RRSet(resp.Answer))
sort.Sort(test.RRSet(resp.Ns))
sort.Sort(test.RRSet(resp.Extra))
if !test.Header(t, tc, resp) {
t.Logf("%v\n", resp)
continue
}
if !test.Section(t, tc, test.Answer, resp.Answer) {
t.Logf("%v\n", resp)
}
if !test.Section(t, tc, test.Ns, resp.Ns) {
t.Logf("%v\n", resp)
}
if !test.Section(t, tc, test.Extra, resp.Extra) {
t.Logf("%v\n", resp)
}
test.SortAndCheck(t, resp, tc)
}
}

View file

@ -1,7 +1,6 @@
package file
import (
"sort"
"strings"
"testing"
@ -53,25 +52,7 @@ func TestLookupGlue(t *testing.T) {
}
resp := rec.Msg
sort.Sort(test.RRSet(resp.Answer))
sort.Sort(test.RRSet(resp.Ns))
sort.Sort(test.RRSet(resp.Extra))
if !test.Header(t, tc, resp) {
t.Logf("%v\n", resp)
continue
}
if !test.Section(t, tc, test.Answer, resp.Answer) {
t.Logf("%v\n", resp)
}
if !test.Section(t, tc, test.Ns, resp.Ns) {
t.Logf("%v\n", resp)
}
if !test.Section(t, tc, test.Extra, resp.Extra) {
t.Logf("%v\n", resp)
}
test.SortAndCheck(t, resp, tc)
}
}

View file

@ -1,7 +1,6 @@
package file
import (
"sort"
"strings"
"testing"
@ -123,25 +122,7 @@ func TestLookup(t *testing.T) {
}
resp := rec.Msg
sort.Sort(test.RRSet(resp.Answer))
sort.Sort(test.RRSet(resp.Ns))
sort.Sort(test.RRSet(resp.Extra))
if !test.Header(t, tc, resp) {
t.Logf("%v\n", resp)
continue
}
if !test.Section(t, tc, test.Answer, resp.Answer) {
t.Logf("%v\n", resp)
}
if !test.Section(t, tc, test.Ns, resp.Ns) {
t.Logf("%v\n", resp)
}
if !test.Section(t, tc, test.Extra, resp.Extra) {
t.Logf("%v\n", resp)
}
test.SortAndCheck(t, resp, tc)
}
}

View file

@ -1,7 +1,6 @@
package file
import (
"sort"
"strings"
"testing"
@ -98,23 +97,7 @@ func TestLookupWildcard(t *testing.T) {
}
resp := rec.Msg
sort.Sort(test.RRSet(resp.Answer))
sort.Sort(test.RRSet(resp.Ns))
sort.Sort(test.RRSet(resp.Extra))
if !test.Header(t, tc, resp) {
t.Logf("%v\n", resp)
continue
}
if !test.Section(t, tc, test.Answer, resp.Answer) {
t.Logf("%v\n", resp)
}
if !test.Section(t, tc, test.Ns, resp.Ns) {
t.Logf("%v\n", resp)
}
if !test.Section(t, tc, test.Extra, resp.Extra) {
t.Logf("%v\n", resp)
}
test.SortAndCheck(t, resp, tc)
}
}
@ -175,23 +158,7 @@ func TestLookupDoubleWildcard(t *testing.T) {
}
resp := rec.Msg
sort.Sort(test.RRSet(resp.Answer))
sort.Sort(test.RRSet(resp.Ns))
sort.Sort(test.RRSet(resp.Extra))
if !test.Header(t, tc, resp) {
t.Logf("%v\n", resp)
continue
}
if !test.Section(t, tc, test.Answer, resp.Answer) {
t.Logf("%v\n", resp)
}
if !test.Section(t, tc, test.Ns, resp.Ns) {
t.Logf("%v\n", resp)
}
if !test.Section(t, tc, test.Extra, resp.Extra) {
t.Logf("%v\n", resp)
}
test.SortAndCheck(t, resp, tc)
}
}
@ -246,23 +213,7 @@ func TestLookupApexWildcard(t *testing.T) {
}
resp := rec.Msg
sort.Sort(test.RRSet(resp.Answer))
sort.Sort(test.RRSet(resp.Ns))
sort.Sort(test.RRSet(resp.Extra))
if !test.Header(t, tc, resp) {
t.Logf("%v\n", resp)
continue
}
if !test.Section(t, tc, test.Answer, resp.Answer) {
t.Logf("%v\n", resp)
}
if !test.Section(t, tc, test.Ns, resp.Ns) {
t.Logf("%v\n", resp)
}
if !test.Section(t, tc, test.Extra, resp.Extra) {
t.Logf("%v\n", resp)
}
test.SortAndCheck(t, resp, tc)
}
}
@ -305,23 +256,7 @@ func TestLookupMultiWildcard(t *testing.T) {
}
resp := rec.Msg
sort.Sort(test.RRSet(resp.Answer))
sort.Sort(test.RRSet(resp.Ns))
sort.Sort(test.RRSet(resp.Extra))
if !test.Header(t, tc, resp) {
t.Logf("%v\n", resp)
continue
}
if !test.Section(t, tc, test.Answer, resp.Answer) {
t.Logf("%v\n", resp)
}
if !test.Section(t, tc, test.Ns, resp.Ns) {
t.Logf("%v\n", resp)
}
if !test.Section(t, tc, test.Extra, resp.Extra) {
t.Logf("%v\n", resp)
}
test.SortAndCheck(t, resp, tc)
}
}

View file

@ -1,7 +1,6 @@
package hosts
import (
"sort"
"strings"
"testing"
"time"
@ -30,25 +29,7 @@ func TestLookupA(t *testing.T) {
}
resp := rec.Msg
sort.Sort(test.RRSet(resp.Answer))
sort.Sort(test.RRSet(resp.Ns))
sort.Sort(test.RRSet(resp.Extra))
if !test.Header(t, tc, resp) {
t.Logf("%v\n", resp)
continue
}
if !test.Section(t, tc, test.Answer, resp.Answer) {
t.Logf("%v\n", resp)
}
if !test.Section(t, tc, test.Ns, resp.Ns) {
t.Logf("%v\n", resp)
}
if !test.Section(t, tc, test.Extra, resp.Extra) {
t.Logf("%v\n", resp)
}
test.SortAndCheck(t, resp, tc)
}
}

View file

@ -1,7 +1,6 @@
package kubernetes
import (
"sort"
"testing"
"github.com/coredns/coredns/middleware/pkg/dnsrecorder"
@ -201,24 +200,7 @@ func runServeDNSTests(ctx context.Context, t *testing.T, dnsTestCases map[string
}
}
sort.Sort(test.RRSet(resp.Answer))
sort.Sort(test.RRSet(resp.Ns))
sort.Sort(test.RRSet(resp.Extra))
if !test.Header(t, tc, resp) {
t.Logf("%v Received:\n %v\n", testname, resp)
continue
}
if !test.Section(t, tc, test.Answer, resp.Answer) {
t.Logf("%v Received:\n %v\n", testname, resp)
}
if !test.Section(t, tc, test.Ns, resp.Ns) {
t.Logf("%v Received:\n %v\n", testname, resp)
}
if !test.Section(t, tc, test.Extra, resp.Extra) {
t.Logf("%v Received:\n %v\n", testname, resp)
}
test.SortAndCheck(t, resp, tc)
}
}

View file

@ -1,7 +1,6 @@
package kubernetes
import (
"sort"
"testing"
"github.com/coredns/coredns/middleware/pkg/dnsrecorder"
@ -118,23 +117,6 @@ func TestReverse(t *testing.T) {
if resp == nil {
t.Fatalf("Test %d: got nil message and no error for: %s %d", i, r.Question[0].Name, r.Question[0].Qtype)
}
sort.Sort(test.RRSet(resp.Answer))
sort.Sort(test.RRSet(resp.Ns))
sort.Sort(test.RRSet(resp.Extra))
if !test.Header(t, tc, resp) {
t.Logf("Test %d, received: %v", i, resp)
continue
}
if !test.Section(t, tc, test.Answer, resp.Answer) {
t.Logf("Test %d, received: %v", i, resp)
}
if !test.Section(t, tc, test.Ns, resp.Ns) {
t.Logf("Test %d, received: %v", i, resp)
}
if !test.Section(t, tc, test.Extra, resp.Extra) {
t.Logf("Test %d, received: %v", i, resp)
}
test.SortAndCheck(t, resp, tc)
}
}

View file

@ -1,6 +1,7 @@
package test
import (
"sort"
"testing"
"github.com/miekg/dns"
@ -263,6 +264,33 @@ func Section(t *testing.T, tc Case, sec sect, rr []dns.RR) bool {
return true
}
// SortAndCheck sorts resp and the checks the header and three sections against the testcase in tc.
func SortAndCheck(t *testing.T, resp *dns.Msg, tc Case) {
sort.Sort(RRSet(resp.Answer))
sort.Sort(RRSet(resp.Ns))
sort.Sort(RRSet(resp.Extra))
if !Header(t, tc, resp) {
t.Logf("%v\n", resp)
return
}
if !Section(t, tc, Answer, resp.Answer) {
t.Logf("%v\n", resp)
return
}
if !Section(t, tc, Ns, resp.Ns) {
t.Logf("%v\n", resp)
return
}
if !Section(t, tc, Extra, resp.Extra) {
t.Logf("%v\n", resp)
return
}
return
}
// ErrorHandler returns a Handler that returns ServerFailure error when called.
func ErrorHandler() Handler {
return HandlerFunc(func(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) {

View file

@ -1,8 +0,0 @@
package test
import "testing"
func TestA(t *testing.T) {
// should not crash
A("miek.nl. IN A 127.0.0.1")
}

View file

@ -3,7 +3,6 @@ package test
import (
"io/ioutil"
"log"
"sort"
"testing"
"github.com/coredns/coredns/middleware/proxy"
@ -66,22 +65,6 @@ func TestLookupDS(t *testing.T) {
t.Fatalf("Expected to receive reply, but didn't for %s %d", tc.Qname, tc.Qtype)
}
sort.Sort(mtest.RRSet(resp.Answer))
sort.Sort(mtest.RRSet(resp.Ns))
sort.Sort(mtest.RRSet(resp.Extra))
if !mtest.Header(t, tc, resp) {
t.Logf("%v\n", resp)
continue
}
if !mtest.Section(t, tc, mtest.Answer, resp.Answer) {
t.Logf("%v\n", resp)
}
if !mtest.Section(t, tc, mtest.Ns, resp.Ns) {
t.Logf("%v\n", resp)
}
if !mtest.Section(t, tc, mtest.Extra, resp.Extra) {
t.Logf("%v\n", resp)
}
mtest.SortAndCheck(t, resp, tc)
}
}