mirror of
https://github.com/coredns/coredns.git
synced 2025-08-06 14:27:03 +02:00
plugin/test: fix TXT record comparison for multi-chunk vs multiple records (#7413)
This commit is contained in:
parent
d5932041f7
commit
1981f22170
@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"sort"
|
"sort"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/miekg/dns"
|
"github.com/miekg/dns"
|
||||||
)
|
)
|
||||||
@ -206,11 +207,12 @@ func Section(tc Case, sec sect, rr []dns.RR) error {
|
|||||||
return fmt.Errorf("RR %d should have a Address of %q, but has %q", i, section[i].(*dns.AAAA).AAAA.String(), x.AAAA.String())
|
return fmt.Errorf("RR %d should have a Address of %q, but has %q", i, section[i].(*dns.AAAA).AAAA.String(), x.AAAA.String())
|
||||||
}
|
}
|
||||||
case *dns.TXT:
|
case *dns.TXT:
|
||||||
for j, txt := range x.Txt {
|
actualTxt := strings.Join(x.Txt, "")
|
||||||
if txt != section[i].(*dns.TXT).Txt[j] {
|
expectedTxt := strings.Join(section[i].(*dns.TXT).Txt, "")
|
||||||
return fmt.Errorf("RR %d should have a Txt of %q, but has %q", i, section[i].(*dns.TXT).Txt[j], txt)
|
if actualTxt != expectedTxt {
|
||||||
}
|
return fmt.Errorf("RR %d should have a TXT value of %q, but has %q", i, expectedTxt, actualTxt)
|
||||||
}
|
}
|
||||||
|
|
||||||
case *dns.HINFO:
|
case *dns.HINFO:
|
||||||
if x.Cpu != section[i].(*dns.HINFO).Cpu {
|
if x.Cpu != section[i].(*dns.HINFO).Cpu {
|
||||||
return fmt.Errorf("RR %d should have a Cpu of %s, but has %s", i, section[i].(*dns.HINFO).Cpu, x.Cpu)
|
return fmt.Errorf("RR %d should have a Cpu of %s, but has %s", i, section[i].(*dns.HINFO).Cpu, x.Cpu)
|
||||||
|
15
plugin/test/testdata/txtrecordsplit.test
vendored
Normal file
15
plugin/test/testdata/txtrecordsplit.test
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
; This record has two separate TXT records
|
||||||
|
example.org. 3600 IN TXT "record1"
|
||||||
|
example.org. 3600 IN TXT "record2"
|
||||||
|
|
||||||
|
; This record has a single TXT record split into two chunks (>255 bytes total)
|
||||||
|
long.example.org. 3600 IN TXT "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
|
||||||
|
|
||||||
|
-- QNAME example.org. QTYPE TXT
|
||||||
|
;; ANSWER
|
||||||
|
example.org. 3600 IN TXT "record1"
|
||||||
|
example.org. 3600 IN TXT "record2"
|
||||||
|
|
||||||
|
-- QNAME long.example.org. QTYPE TXT
|
||||||
|
;; ANSWER
|
||||||
|
long.example.org. 3600 IN TXT "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
|
22
plugin/test/testdata_test.go
Normal file
22
plugin/test/testdata_test.go
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func RunTestFile(t *testing.T, filename string) {
|
||||||
|
t.Helper()
|
||||||
|
|
||||||
|
f, err := os.Open(filename)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("failed to open test file: %v", err)
|
||||||
|
}
|
||||||
|
defer f.Close()
|
||||||
|
|
||||||
|
t.Logf("Test file opened successfully: %s", filename)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestTXTRecordSplit(t *testing.T) {
|
||||||
|
RunTestFile(t, "testdata/txtrecordsplit.test")
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user