@@ -1516,14 +1516,12 @@ func TestNewTXTScheme(t *testing.T) {
1516
1516
1517
1517
func TestGenerateTXT (t * testing.T ) {
1518
1518
record := newEndpointWithOwner ("foo.test-zone.example.org" , "new-foo.loadbalancer.com" , endpoint .RecordTypeCNAME , "owner" )
1519
- expectedTXT := []* endpoint.Endpoint {
1520
- {
1521
- DNSName : "cname-foo.test-zone.example.org" ,
1522
- Targets : endpoint.Targets {"\" heritage=external-dns,external-dns/owner=owner\" " },
1523
- RecordType : endpoint .RecordTypeTXT ,
1524
- Labels : map [string ]string {
1525
- endpoint .OwnedRecordLabelKey : "foo.test-zone.example.org" ,
1526
- },
1519
+ expectedTXT := & endpoint.Endpoint {
1520
+ DNSName : "cname-foo.test-zone.example.org" ,
1521
+ Targets : endpoint.Targets {"\" heritage=external-dns,external-dns/owner=owner\" " },
1522
+ RecordType : endpoint .RecordTypeTXT ,
1523
+ Labels : map [string ]string {
1524
+ endpoint .OwnedRecordLabelKey : "foo.test-zone.example.org" ,
1527
1525
},
1528
1526
}
1529
1527
p := inmemory .NewInMemoryProvider ()
@@ -1535,14 +1533,12 @@ func TestGenerateTXT(t *testing.T) {
1535
1533
1536
1534
func TestGenerateTXTForAAAA (t * testing.T ) {
1537
1535
record := newEndpointWithOwner ("foo.test-zone.example.org" , "2001:DB8::1" , endpoint .RecordTypeAAAA , "owner" )
1538
- expectedTXT := []* endpoint.Endpoint {
1539
- {
1540
- DNSName : "aaaa-foo.test-zone.example.org" ,
1541
- Targets : endpoint.Targets {"\" heritage=external-dns,external-dns/owner=owner\" " },
1542
- RecordType : endpoint .RecordTypeTXT ,
1543
- Labels : map [string ]string {
1544
- endpoint .OwnedRecordLabelKey : "foo.test-zone.example.org" ,
1545
- },
1536
+ expectedTXT := & endpoint.Endpoint {
1537
+ DNSName : "aaaa-foo.test-zone.example.org" ,
1538
+ Targets : endpoint.Targets {"\" heritage=external-dns,external-dns/owner=owner\" " },
1539
+ RecordType : endpoint .RecordTypeTXT ,
1540
+ Labels : map [string ]string {
1541
+ endpoint .OwnedRecordLabelKey : "foo.test-zone.example.org" ,
1546
1542
},
1547
1543
}
1548
1544
p := inmemory .NewInMemoryProvider ()
@@ -1560,8 +1556,8 @@ func TestFailGenerateTXT(t *testing.T) {
1560
1556
RecordType : endpoint .RecordTypeCNAME ,
1561
1557
Labels : map [string ]string {},
1562
1558
}
1563
- // A bad DNS name returns empty expected TXT
1564
- expectedTXT := [] * endpoint.Endpoint {}
1559
+ // A bad DNS name returns nil
1560
+ var expectedTXT * endpoint.Endpoint
1565
1561
p := inmemory .NewInMemoryProvider ()
1566
1562
p .CreateZone (testZone )
1567
1563
r , _ := NewTXTRegistry (p , "" , "" , "owner" , time .Hour , "" , []string {}, []string {}, false , nil )
@@ -1714,23 +1710,14 @@ func TestGenerateTXTRecordWithNewFormatOnly(t *testing.T) {
1714
1710
for _ , tc := range testCases {
1715
1711
t .Run (tc .name , func (t * testing.T ) {
1716
1712
r , _ := NewTXTRegistry (p , "" , "" , "owner" , time .Hour , "" , []string {}, []string {}, false , nil )
1717
- records := r .generateTXTRecord (tc .endpoint )
1713
+ txt := r .generateTXTRecord (tc .endpoint )
1718
1714
1719
- assert .Len (t , records , tc . expectedRecords , tc .description )
1715
+ assert .NotNil (t , txt , tc .description )
1720
1716
1721
- for _ , record := range records {
1722
- assert .Equal (t , endpoint .RecordTypeTXT , record .RecordType )
1723
- }
1717
+ assert .Equal (t , endpoint .RecordTypeTXT , txt .RecordType )
1724
1718
1725
1719
if tc .endpoint .RecordType == endpoint .RecordTypeAAAA {
1726
- hasNewFormat := false
1727
- for _ , record := range records {
1728
- if strings .HasPrefix (record .DNSName , tc .expectedPrefix ) {
1729
- hasNewFormat = true
1730
- break
1731
- }
1732
- }
1733
- assert .True (t , hasNewFormat ,
1720
+ assert .True (t , strings .HasPrefix (txt .DNSName , tc .expectedPrefix ),
1734
1721
"Should have at least one record with prefix %s when using new format" , tc .expectedPrefix )
1735
1722
}
1736
1723
})
0 commit comments