github.com/philhug/dnscontrol@v0.2.4-0.20180625181521-921fa9849001/providers/activedir/domains_test.go (about) 1 package activedir 2 3 import ( 4 "fmt" 5 "testing" 6 7 "github.com/StackExchange/dnscontrol/models" 8 ) 9 10 func makeRC(label, domain, target string, rc models.RecordConfig) *models.RecordConfig { 11 rc.SetLabel(label, domain) 12 rc.SetTarget(target) 13 return &rc 14 } 15 16 func TestGetExistingRecords(t *testing.T) { 17 18 cf := &adProvider{} 19 20 cf.fake = true 21 actual, err := cf.getExistingRecords("test2") 22 if err != nil { 23 t.Fatal(err) 24 } 25 expected := []*models.RecordConfig{ 26 makeRC("@", "test2", "10.166.2.11", models.RecordConfig{Type: "A", TTL: 600}), 27 //makeRC("_msdcs", "test2", "other_record", models.RecordConfig{Type: "NS", TTL: 300}), // Will be filtered. 28 makeRC("co-devsearch02", "test2", "10.8.2.64", models.RecordConfig{Type: "A", TTL: 3600}), 29 makeRC("co-devservice01", "test2", "10.8.2.48", models.RecordConfig{Type: "A", TTL: 1200}), // Downcased. 30 makeRC("yum", "test2", "10.8.0.59", models.RecordConfig{Type: "A", TTL: 3600}), 31 } 32 33 actualS := "" 34 for i, x := range actual { 35 actualS += fmt.Sprintf("%d %v\n", i, x) 36 } 37 38 expectedS := "" 39 for i, x := range expected { 40 expectedS += fmt.Sprintf("%d %v\n", i, x) 41 } 42 43 if actualS != expectedS { 44 t.Fatalf("got\n(%s)\nbut expected\n(%s)", actualS, expectedS) 45 } 46 }