mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2025-01-11 01:47:53 +08:00
87ad01d194
* Add GetZoneRecords to DNSProvider interface * dnscontrol now uses ufave/cli/v2 * NEW: get-zones.md * HasRecordTypeName should be a method on models.Records not models.DomainConfig * Implement BIND's GetZoneRecords * new WriteZoneFile implemented * go mod vendor * Update docs to use get-zone instead of convertzone * Add CanGetZone capability and update all providers. * Get all zones for a provider at once (#626) * implement GetZoneRecords for cloudflare * munge cloudflare ttls * Implement GetZoneRecords for cloudflare (#625) Co-authored-by: Craig Peterson <192540+captncraig@users.noreply.github.com>
51 lines
1.3 KiB
Go
51 lines
1.3 KiB
Go
package models
|
|
|
|
import "testing"
|
|
|
|
func TestHasRecordTypeName(t *testing.T) {
|
|
x := &RecordConfig{
|
|
Type: "A",
|
|
Name: "@",
|
|
}
|
|
recs := Records{}
|
|
if recs.HasRecordTypeName("A", "@") {
|
|
t.Errorf("%v: expected (%v) got (%v)\n", recs, false, true)
|
|
}
|
|
recs = append(recs, x)
|
|
if !recs.HasRecordTypeName("A", "@") {
|
|
t.Errorf("%v: expected (%v) got (%v)\n", recs, true, false)
|
|
}
|
|
if recs.HasRecordTypeName("AAAA", "@") {
|
|
t.Errorf("%v: expected (%v) got (%v)\n", recs, false, true)
|
|
}
|
|
}
|
|
|
|
func TestKey(t *testing.T) {
|
|
var tests = []struct {
|
|
rc RecordConfig
|
|
expected RecordKey
|
|
}{
|
|
{
|
|
RecordConfig{Type: "A", NameFQDN: "example.com"},
|
|
RecordKey{Type: "A", NameFQDN: "example.com"},
|
|
},
|
|
{
|
|
RecordConfig{Type: "R53_ALIAS", NameFQDN: "example.com"},
|
|
RecordKey{Type: "R53_ALIAS", NameFQDN: "example.com"},
|
|
},
|
|
{
|
|
RecordConfig{Type: "R53_ALIAS", NameFQDN: "example.com", R53Alias: map[string]string{"foo": "bar"}},
|
|
RecordKey{Type: "R53_ALIAS", NameFQDN: "example.com"},
|
|
},
|
|
{
|
|
RecordConfig{Type: "R53_ALIAS", NameFQDN: "example.com", R53Alias: map[string]string{"type": "AAAA"}},
|
|
RecordKey{Type: "R53_ALIAS_AAAA", NameFQDN: "example.com"},
|
|
},
|
|
}
|
|
for i, test := range tests {
|
|
actual := test.rc.Key()
|
|
if test.expected != actual {
|
|
t.Errorf("%d: Expected %s, got %s", i, test.expected, actual)
|
|
}
|
|
}
|
|
}
|