2021-03-08 04:14:46 +08:00
|
|
|
package gandi_v5
|
2020-01-21 03:13:32 +08:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2020-04-15 04:47:30 +08:00
|
|
|
"github.com/StackExchange/dnscontrol/v3/models"
|
2020-01-21 03:13:32 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestRecordsToNative_1(t *testing.T) {
|
|
|
|
var rcs = []*models.RecordConfig{{}}
|
|
|
|
rcs[0].SetLabelFromFQDN("foo.example.com", "example.com")
|
|
|
|
rcs[0].Type = "A"
|
|
|
|
rcs[0].SetTarget("1.2.3.4")
|
|
|
|
|
|
|
|
ns := recordsToNative(rcs, "example.com")
|
|
|
|
|
|
|
|
if len(ns) != 1 {
|
|
|
|
t.Errorf("len(ns) != 1; got=%v", len(ns))
|
|
|
|
}
|
|
|
|
if len(ns[0].RrsetValues) != 1 {
|
|
|
|
t.Errorf("len(ns[0].RrsetValues) != 1; got=%v", ns[0].RrsetValues)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestRecordsToNative_2(t *testing.T) {
|
|
|
|
var rcs = []*models.RecordConfig{{}, {}}
|
|
|
|
rcs[0].SetLabelFromFQDN("foo.example.com", "example.com")
|
|
|
|
rcs[0].Type = "A"
|
|
|
|
rcs[0].SetTarget("1.2.3.4")
|
|
|
|
rcs[1].SetLabelFromFQDN("foo.example.com", "example.com")
|
|
|
|
rcs[1].Type = "A"
|
|
|
|
rcs[1].SetTarget("5.6.7.8")
|
|
|
|
|
|
|
|
ns := recordsToNative(rcs, "example.com")
|
|
|
|
|
|
|
|
if len(ns) != 1 {
|
|
|
|
t.Errorf("len(ns) != 1; got=%v", len(ns))
|
|
|
|
}
|
|
|
|
if len(ns[0].RrsetValues) != 2 {
|
|
|
|
t.Errorf("len(ns[0].RrsetValues) != 2; got=%v", ns[0].RrsetValues)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|