CHORE: Move NS test to its own function (#2318)

Co-authored-by: Tom Limoncelli <tal@whatexit.org>
This commit is contained in:
Tom Limoncelli 2023-05-07 09:27:41 -04:00 committed by GitHub
parent 00976474cb
commit ebe3ecdf8f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 10 deletions

3
go.mod
View file

@ -2,8 +2,6 @@ module github.com/StackExchange/dnscontrol/v3
go 1.18
require gopkg.in/yaml.v3 v3.0.1
require (
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns v1.1.0
@ -67,6 +65,7 @@ require (
github.com/vultr/govultr/v2 v2.17.2
golang.org/x/exp v0.0.0-20230425010034-47ecfdc1ba53
golang.org/x/text v0.9.0
gopkg.in/yaml.v3 v3.0.1
)
require (

View file

@ -319,14 +319,6 @@ func runTests(t *testing.T, prv providers.DNSServiceProvider, domainName string,
}
// Issue https://github.com/StackExchange/dnscontrol/issues/491
t.Run("No trailing dot in nameserver", func(t *testing.T) {
for _, nameserver := range dc.Nameservers {
if strings.HasSuffix(nameserver.Name, ".") {
t.Errorf("Provider returned nameserver with trailing dot: %s (See issue https://github.com/StackExchange/dnscontrol/issues/491, TL;DR: use models.ToNameserversStripTD in GetNameservers)", nameserver)
}
}
})
}
func TestDualProviders(t *testing.T) {
@ -381,6 +373,36 @@ func TestDualProviders(t *testing.T) {
}
}
func TestNameserverDots(t *testing.T) {
// Issue https://github.com/StackExchange/dnscontrol/issues/491
// If this fails, the provider's GetNameservers() function uses
// models.ToNameserversStripTD() instead of models.ToNameservers()
// or vise-versa.
// Setup:
p, domain, _, _ := getProvider(t)
if p == nil {
return
}
if domain == "" {
t.Fatal("NO DOMAIN SET! Exiting!")
}
dc := getDomainConfigWithNameservers(t, p, domain)
if !providers.ProviderHasCapability(*providerToRun, providers.DocDualHost) {
t.Skip("Skipping. DocDualHost == Cannot")
return
}
t.Run("No trailing dot in nameserver", func(t *testing.T) {
for _, nameserver := range dc.Nameservers {
//fmt.Printf("DEBUG: nameserver.Name = %q\n", nameserver.Name)
if strings.HasSuffix(nameserver.Name, ".") {
t.Errorf("Provider returned nameserver with trailing dot: %q", nameserver)
}
}
})
}
type TestGroup struct {
Desc string
required []providers.Capability