mirror of
https://github.com/coredns/coredns.git
synced 2025-08-06 06:17:00 +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"
|
||||
"fmt"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"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())
|
||||
}
|
||||
case *dns.TXT:
|
||||
for j, txt := range x.Txt {
|
||||
if txt != section[i].(*dns.TXT).Txt[j] {
|
||||
return fmt.Errorf("RR %d should have a Txt of %q, but has %q", i, section[i].(*dns.TXT).Txt[j], txt)
|
||||
}
|
||||
actualTxt := strings.Join(x.Txt, "")
|
||||
expectedTxt := strings.Join(section[i].(*dns.TXT).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:
|
||||
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)
|
||||
|
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 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
|
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