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

checking only one cname on a name (#81)

This commit is contained in:
Craig Peterson
2017-04-13 11:10:15 -06:00
committed by GitHub
parent 3c22807b91
commit 0203b3eebc
2 changed files with 53 additions and 0 deletions

View File

@ -3,6 +3,8 @@ package normalize
import (
"testing"
"fmt"
"github.com/StackExchange/dnscontrol/models"
)
@ -137,3 +139,33 @@ func TestTransforms(t *testing.T) {
}
}
}
func TestCNAMEMutex(t *testing.T) {
var recA = &models.RecordConfig{Type: "CNAME", Name: "foo", NameFQDN: "foo.example.com", Target: "example.com."}
tests := []struct {
rType string
name string
fail bool
}{
{"A", "foo", true},
{"A", "foo2", false},
{"CNAME", "foo", true},
{"CNAME", "foo2", false},
}
for _, tst := range tests {
t.Run(fmt.Sprintf("%s %s", tst.rType, tst.name), func(t *testing.T) {
var recB = &models.RecordConfig{Type: tst.rType, Name: tst.name, NameFQDN: tst.name + ".example.com", Target: "example2.com."}
dc := &models.DomainConfig{
Name: "example.com",
Records: []*models.RecordConfig{recA, recB},
}
errs := checkCNAMEs(dc)
if errs != nil && !tst.fail {
t.Error("Got error but expected none")
}
if errs == nil && tst.fail {
t.Error("Expected error but got none")
}
})
}
}