From e7db933249e518c4727159ea4c3347e7f7ec24ec Mon Sep 17 00:00:00 2001 From: upsaurav12 Date: Thu, 22 May 2025 23:37:00 +0530 Subject: [PATCH] test(provider/gandi): bumped to 100% coverage --- provider/gandi/gandi_test.go | 40 ++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/provider/gandi/gandi_test.go b/provider/gandi/gandi_test.go index e3b4cca19..dc50d1ab2 100644 --- a/provider/gandi/gandi_test.go +++ b/provider/gandi/gandi_test.go @@ -452,6 +452,46 @@ func TestGandiProvider_ApplyChangesWithUnknownDomainDoesNoUpdate(t *testing.T) { }) } +func TestGandiProvider_ApplyChangesConvertsApexDomain(t *testing.T) { + changes := &plan.Changes{} + mockedClient := &mockGandiClient{} + mockedProvider := &GandiProvider{ + DomainClient: mockedClient, + LiveDNSClient: mockedClient, + } + + // Add a change where DNSName equals the zone name (apex domain) + changes.Create = []*endpoint.Endpoint{ + { + DNSName: "example.com", // Matches the zone name + Targets: endpoint.Targets{"192.168.0.1"}, + RecordType: "A", + RecordTTL: 666, + }, + } + + err := mockedProvider.ApplyChanges(context.Background(), changes) + if err != nil { + t.Errorf("should not fail, %s", err) + } + + td.Cmp(t, mockedClient.Actions, []MockAction{ + { + Name: "ListDomains", + }, + { + Name: "CreateDomainRecord", + FQDN: "example.com", + Record: livedns.DomainRecord{ + RrsetType: endpoint.RecordTypeA, + RrsetName: "@", + RrsetValues: []string{"192.168.0.1"}, + RrsetTTL: 666, + }, + }, + }) +} + func TestGandiProvider_FailingCases(t *testing.T) { changes := &plan.Changes{} changes.Create = []*endpoint.Endpoint{{DNSName: "test2.example.com", Targets: endpoint.Targets{"192.168.0.1"}, RecordType: "A", RecordTTL: 666}}