dnscontrol/models/tonameservers_test.go
Tom Limoncelli 3f68215841
GetNameservers is inconsistent across providers (#655)
* Warn if GetNameservers returns FQDN+dot strings
* Simplify logic that covers for the inconsistency
* Fix azuredns, gcloud, bind, route53
* Clean up cloudflare, digitalocean, dnsimple, gandi_v5, namedotcom
2020-03-01 10:33:24 -05:00

51 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)
}
}