From a5efc4094d950d7d4d361cabf571d85c5bc2a2b7 Mon Sep 17 00:00:00 2001 From: u-kai <76635578+u-kai@users.noreply.github.com> Date: Thu, 31 Jul 2025 07:32:00 +0900 Subject: [PATCH] fix txt_test.go --- registry/txt_test.go | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/registry/txt_test.go b/registry/txt_test.go index 812cf2a95..7efa534c3 100644 --- a/registry/txt_test.go +++ b/registry/txt_test.go @@ -1926,8 +1926,30 @@ func TestTXTRegistryRecreatesMissingRecords(t *testing.T) { newEndpointWithOwner("record-1.test-zone.example.org", "1.1.1.1", endpoint.RecordTypeA, ownerId), }, }, - // TODO: Test TXT record regeneration when only A/CNAME records exist. - // The regeneration logic will be introduced in a separate PR. + { + name: "Should not recreate TXT records for existing A records without owner", + desired: []*endpoint.Endpoint{ + newEndpointWithOwner("record-1.test-zone.example.org", "1.1.1.1", endpoint.RecordTypeA, ""), + }, + existing: []*endpoint.Endpoint{ + newEndpointWithOwner("record-1.test-zone.example.org", "1.1.1.1", endpoint.RecordTypeA, ownerId), + // Missing TXT record for the existing A record + }, + expectedCreate: []*endpoint.Endpoint{}, + }, + { + name: "Should not recreate TXT records for existing A records with another owner", + desired: []*endpoint.Endpoint{ + newEndpointWithOwner("record-1.test-zone.example.org", "1.1.1.1", endpoint.RecordTypeA, ""), + }, + existing: []*endpoint.Endpoint{ + // This test uses the `ownerId` variable, and "another-owner" simulates a different owner. + // In this case, TXT records should not be recreated. + newEndpointWithOwner("record-1.test-zone.example.org", "1.1.1.1", endpoint.RecordTypeA, "another-owner"), + newEndpointWithOwner("a-record-1.test-zone.example.org", "\"heritage=external-dns,external-dns/owner="+"another-owner"+"\"", endpoint.RecordTypeTXT, "another-owner"), + }, + expectedCreate: []*endpoint.Endpoint{}, + }, } for _, tt := range tests { for _, setIdentifier := range []string{"", "set-identifier"} {