mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2025-01-11 01:47:53 +08:00
ccb582b278
* Remove deprecated io/ioutil * fixup! * staticcheck and linting * revert models/provider.go * Fix imports to new style * linting
49 lines
1.1 KiB
Go
49 lines
1.1 KiB
Go
package models
|
|
|
|
import "testing"
|
|
|
|
func TestToNameservers(t *testing.T) {
|
|
nss, e := ToNameservers([]string{"example.com", "example2.tld"})
|
|
if e != nil {
|
|
t.Errorf("error e %v (%v)", e, nss)
|
|
}
|
|
if len(nss) != 2 {
|
|
t.Errorf("error len: %v", nss)
|
|
}
|
|
if nss[0].Name != "example.com" {
|
|
t.Errorf("error 0: %v", nss[0].Name)
|
|
}
|
|
if nss[1].Name != "example2.tld" {
|
|
t.Errorf("error 1: %v", nss[1].Name)
|
|
}
|
|
}
|
|
|
|
func TestToNameservers_neg(t *testing.T) {
|
|
nss, e := ToNameservers([]string{"example.com.", "example2.tld."})
|
|
if e == nil {
|
|
t.Errorf("error 3 (%v)", nss)
|
|
}
|
|
}
|
|
|
|
func TestToNameserversStripTD(t *testing.T) {
|
|
nss, e := ToNameserversStripTD([]string{"example.com.", "example2.tld."})
|
|
if e != nil {
|
|
t.Errorf("error e %v (%v)", e, nss)
|
|
}
|
|
if len(nss) != 2 {
|
|
t.Errorf("error len: %v", nss)
|
|
}
|
|
if nss[0].Name != "example.com" {
|
|
t.Errorf("error 0: %v", nss[0].Name)
|
|
}
|
|
if nss[1].Name != "example2.tld" {
|
|
t.Errorf("error 1: %v", nss[1].Name)
|
|
}
|
|
}
|
|
|
|
func TestToNameserversStripTD_neg(t *testing.T) {
|
|
nss, e := ToNameserversStripTD([]string{"example.com", "example2.tld"})
|
|
if e == nil {
|
|
t.Errorf("error e (%v)", nss)
|
|
}
|
|
}
|