mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
* BIND: Support TXT records with multiple strings (#289) * ROUTE53: Add support for TXT records with multiple strings (#292)
72 lines
1.3 KiB
Go
72 lines
1.3 KiB
Go
package models
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestIsQuoted(t *testing.T) {
|
|
tests := []struct {
|
|
d1 string
|
|
e1 bool
|
|
}{
|
|
{``, false},
|
|
{`foo`, false},
|
|
{`""`, true},
|
|
{`"a"`, true},
|
|
{`"bb"`, true},
|
|
{`"ccc"`, true},
|
|
{`"aaa" "bbb"`, true},
|
|
}
|
|
for i, test := range tests {
|
|
r := IsQuoted(test.d1)
|
|
if r != test.e1 {
|
|
t.Errorf("%v: expected (%v) got (%v)", i, test.e1, r)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestStripQuotes(t *testing.T) {
|
|
tests := []struct {
|
|
d1 string
|
|
e1 string
|
|
}{
|
|
{``, ``},
|
|
{`a`, `a`},
|
|
{`bb`, `bb`},
|
|
{`ccc`, `ccc`},
|
|
{`dddd`, `dddd`},
|
|
{`"A"`, `A`},
|
|
{`"BB"`, `BB`},
|
|
{`"CCC"`, `CCC`},
|
|
{`"DDDD"`, `DDDD`},
|
|
{`"EEEEE"`, `EEEEE`},
|
|
{`"aaa" "bbb"`, `aaa" "bbb`},
|
|
}
|
|
for i, test := range tests {
|
|
r := StripQuotes(test.d1)
|
|
if r != test.e1 {
|
|
t.Errorf("%v: expected (%v) got (%v)", i, test.e1, r)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestSetTxtParse(t *testing.T) {
|
|
tests := []struct {
|
|
d1 string
|
|
e1 string
|
|
e2 []string
|
|
}{
|
|
{``, ``, []string{``}},
|
|
{`foo`, `foo`, []string{`foo`}},
|
|
{`"foo"`, `foo`, []string{`foo`}},
|
|
{`"aaa" "bbb"`, `aaa`, []string{`aaa`, `bbb`}},
|
|
}
|
|
for i, test := range tests {
|
|
x := &RecordConfig{Type: "TXT"}
|
|
x.SetTxtParse(test.d1)
|
|
if x.Target != test.e1 {
|
|
t.Errorf("%v: expected Target=(%v) got (%v)", i, test.e1, x.Target)
|
|
}
|
|
}
|
|
}
|