Fix XFR tests (#1188)

* Fix XFR tests

axfrTestingSuite returned the test function that was never actually
executed. These were broken from the beginning awkwardly, though the
test cases pass fine once fixed.

* Switch axfrTestingSuite argument order

*testing.T is customarily the first argument.
This commit is contained in:
Tom Thorogood 2020-10-24 22:28:44 +10:30 committed by GitHub
parent 93945c2844
commit a3ad44419a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 22 additions and 24 deletions

View File

@ -84,7 +84,7 @@ func TestSingleEnvelopeXfr(t *testing.T) {
}
defer s.Shutdown()
axfrTestingSuite(addrstr)
axfrTestingSuite(t, addrstr)
}
func TestMultiEnvelopeXfr(t *testing.T) {
@ -97,7 +97,7 @@ func TestMultiEnvelopeXfr(t *testing.T) {
}
defer s.Shutdown()
axfrTestingSuite(addrstr)
axfrTestingSuite(t, addrstr)
}
func RunLocalTCPServerWithTsig(laddr string, tsig map[string]string) (*Server, string, error) {
@ -131,33 +131,31 @@ func RunLocalTCPServerWithFinChanWithTsig(laddr string, tsig map[string]string)
return server, l.Addr().String(), fin, nil
}
func axfrTestingSuite(addrstr string) func(*testing.T) {
return func(t *testing.T) {
tr := new(Transfer)
m := new(Msg)
m.SetAxfr("miek.nl.")
func axfrTestingSuite(t *testing.T, addrstr string) {
tr := new(Transfer)
m := new(Msg)
m.SetAxfr("miek.nl.")
c, err := tr.In(m, addrstr)
if err != nil {
t.Fatal("failed to zone transfer in", err)
c, err := tr.In(m, addrstr)
if err != nil {
t.Fatal("failed to zone transfer in", err)
}
var records []RR
for msg := range c {
if msg.Error != nil {
t.Fatal(msg.Error)
}
records = append(records, msg.RR...)
}
var records []RR
for msg := range c {
if msg.Error != nil {
t.Fatal(msg.Error)
}
records = append(records, msg.RR...)
}
if len(records) != len(xfrTestData) {
t.Fatalf("bad axfr: expected %v, got %v", records, xfrTestData)
}
if len(records) != len(xfrTestData) {
for i, rr := range records {
if !IsDuplicate(rr, xfrTestData[i]) {
t.Fatalf("bad axfr: expected %v, got %v", records, xfrTestData)
}
for i := range records {
if !IsDuplicate(records[i], xfrTestData[i]) {
t.Fatalf("bad axfr: expected %v, got %v", records, xfrTestData)
}
}
}
}