1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00

HEXONET: Support long TXT records and fix whitespace bug (#1283)

* HEXONET: Support for long TXT records

* HEXONET: Revert and update comments in auditrecords.go

* Update auditrecords.go

* HEXONET: Sync TXT support with reality

* Fix the fixed unit tests

Co-authored-by: Burak Tamturk <buraktamturk@gmail.com>
This commit is contained in:
Tom Limoncelli
2021-10-04 12:08:57 -04:00
committed by GitHub
parent eef8c25a95
commit 7f071b4ce8
3 changed files with 21 additions and 37 deletions

View File

@@ -9,16 +9,16 @@ var txtData = []struct {
decoded []string
encoded string
}{
{[]string{`simple`}, `simple`},
{[]string{`changed`}, `changed`},
{[]string{`with spaces`}, `with spaces`},
{[]string{`with whitespace`}, `with whitespace`},
{[]string{"one", "two"}, `"one""two"`},
{[]string{"eh", "bee", "cee"}, `"eh""bee""cee"`},
{[]string{"o\"ne", "tw\"o"}, `"o\"ne""tw\"o"`},
{[]string{"dimple"}, `dimple`},
{[]string{"fun", "two"}, `"fun""two"`},
{[]string{"eh", "bzz", "cee"}, `"eh""bzz""cee"`},
{[]string{`simple`}, `"simple"`},
{[]string{`changed`}, `"changed"`},
{[]string{`with spaces`}, `"with spaces"`},
{[]string{`with whitespace`}, `"with whitespace"`},
{[]string{"one", "two"}, `"one" "two"`},
{[]string{"eh", "bee", "cee"}, `"eh" "bee" "cee"`},
{[]string{"o\"ne", "tw\"o"}, `"o\"ne" "tw\"o"`},
{[]string{"dimple"}, `"dimple"`},
{[]string{"fun", "two"}, `"fun" "two"`},
{[]string{"eh", "bzz", "cee"}, `"eh" "bzz" "cee"`},
}
func TestEncodeTxt(t *testing.T) {
@@ -26,7 +26,7 @@ func TestEncodeTxt(t *testing.T) {
for i, test := range txtData {
enc := encodeTxt(test.decoded)
if enc != test.encoded {
t.Errorf("%v: txt\n data: []string{%v}\nexpected: %s\n got: %s",
t.Errorf("%v: txt\n data: []string{%v}\nexpected: %q\n got: %q",
i, "`"+strings.Join(test.decoded, "`, `")+"`", test.encoded, enc)
}
}
@@ -39,11 +39,11 @@ func TestDecodeTxt(t *testing.T) {
got := decodeTxt(data)
wanted := test.decoded
if len(got) != len(wanted) {
t.Errorf("%v: txt\n decode: %v\nexpected: `%v`\n got: `%v`\n", i, data, strings.Join(wanted, "`, `"), strings.Join(got, "`, `"))
t.Errorf("%v: txt\n decode: %v\nexpected: %q\n got: %q\n", i, data, strings.Join(wanted, "`, `"), strings.Join(got, "`, `"))
} else {
for j := range got {
if got[j] != wanted[j] {
t.Errorf("%v: txt\n decode: %v\nexpected: `%v`\n got: `%v`\n", i, data, strings.Join(wanted, "`, `"), strings.Join(got, "`, `"))
t.Errorf("%v: txt\n decode: %v\nexpected: %q\n got: %q\n", i, data, strings.Join(wanted, "`, `"), strings.Join(got, "`, `"))
}
}
}