mirror of
https://github.com/kubernetes-sigs/external-dns.git
synced 2026-05-05 22:56:09 +02:00
test(cloudflare_test): add test for submit changes
This commit is contained in:
parent
612d40fed1
commit
cf1bc0b14b
@ -49,6 +49,7 @@ type mockCloudFlareClient struct {
|
||||
listZonesError error
|
||||
listZonesContextError error
|
||||
dnsRecordsError error
|
||||
dnsRegionError error
|
||||
}
|
||||
|
||||
var ExampleDomain = []cloudflare.DNSRecord{
|
||||
@ -1462,3 +1463,45 @@ func TestCloudFlareProvider_newCloudFlareChange(t *testing.T) {
|
||||
t.Errorf("expected region key to be 'us', but got '%s'", change.RegionalHostname.RegionKey)
|
||||
}
|
||||
}
|
||||
|
||||
// Test basic posible scenarios for the submitChanges function
|
||||
func TestCloudFlareProvider_submitChanges(t *testing.T) {
|
||||
client := NewMockCloudFlareClientWithRecords(map[string][]cloudflare.DNSRecord{
|
||||
"001": {
|
||||
{
|
||||
ID: "1234567890",
|
||||
Name: "bar.com",
|
||||
Type: endpoint.RecordTypeA,
|
||||
TTL: 1,
|
||||
Content: "1.2.3.4",
|
||||
Proxied: proxyEnabled,
|
||||
},
|
||||
},
|
||||
})
|
||||
provider := &CloudFlareProvider{
|
||||
Client: client,
|
||||
}
|
||||
|
||||
// Create a slice of *cloudFlareChange
|
||||
changes := []*cloudFlareChange{
|
||||
{
|
||||
Action: cloudFlareUpdate,
|
||||
ResourceRecord: cloudflare.DNSRecord{
|
||||
Name: "bar.com",
|
||||
Type: "A",
|
||||
ID: "1234567890",
|
||||
Content: "1.2.3.4",
|
||||
},
|
||||
RegionalHostname: cloudflare.RegionalHostname{
|
||||
Hostname: "bar.com",
|
||||
RegionKey: "us",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// Should not return an error
|
||||
err := provider.submitChanges(context.Background(), changes)
|
||||
if err != nil {
|
||||
t.Errorf("should not fail, %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user