@@ -12,6 +12,8 @@ import (
1212 "sigs.k8s.io/external-dns/plan"
1313)
1414
15+ const testDomain = "example.com"
16+
1517func TestFileProvider_Records (t * testing.T ) {
1618 // Create a temporary zone file
1719 zoneContent := `$ORIGIN example.com.
@@ -70,35 +72,35 @@ test 300 IN A 192.168.1.30
7072 switch record .RecordType {
7173 case "A" :
7274 if record .DNSName == "www.example.com" {
73- assert .Equal (t , []string {"192.168.1.10" }, record .Targets )
75+ assert .Equal (t , []string {"192.168.1.10" }, [] string ( record .Targets ) )
7476 foundA = true
7577 } else if record .DNSName == "test.example.com" {
76- assert .Equal (t , []string {"192.168.1.30" }, record .Targets )
78+ assert .Equal (t , []string {"192.168.1.30" }, [] string ( record .Targets ) )
7779 assert .Equal (t , endpoint .TTL (300 ), record .RecordTTL )
7880 }
7981 case "AAAA" :
8082 if record .DNSName == "mail.example.com" {
81- assert .Equal (t , []string {"2001:db8::1" }, record .Targets )
83+ assert .Equal (t , []string {"2001:db8::1" }, [] string ( record .Targets ) )
8284 foundAAAA = true
8385 }
8486 case "CNAME" :
8587 if record .DNSName == "ftp.example.com" {
86- assert .Equal (t , []string {"www.example.com" }, record .Targets )
88+ assert .Equal (t , []string {"www.example.com" }, [] string ( record .Targets ) )
8789 foundCNAME = true
8890 }
8991 case "MX" :
90- if record .DNSName == "example.com" {
91- assert .Equal (t , []string {"10 mail.example.com" }, record .Targets )
92+ if record .DNSName == testDomain {
93+ assert .Equal (t , []string {"10 mail.example.com" }, [] string ( record .Targets ) )
9294 foundMX = true
9395 }
9496 case "TXT" :
95- if record .DNSName == "example.com" {
96- assert .Equal (t , []string {"v=spf1 include:_spf.google.com ~all" }, record .Targets )
97+ if record .DNSName == testDomain {
98+ assert .Equal (t , []string {"v=spf1 include:_spf.google.com ~all" }, [] string ( record .Targets ) )
9799 foundTXT = true
98100 }
99101 case "SRV" :
100102 if record .DNSName == "_sip._tcp.example.com" {
101- assert .Equal (t , []string {"10 5 5060 sip.example.com" }, record .Targets )
103+ assert .Equal (t , []string {"10 5 5060 sip.example.com" }, [] string ( record .Targets ) )
102104 foundSRV = true
103105 }
104106 }
@@ -112,43 +114,6 @@ test 300 IN A 192.168.1.30
112114 assert .True (t , foundSRV , "Should find SRV record" )
113115}
114116
115- func TestFileProvider_ApplyChanges (t * testing.T ) {
116- config := config.FileProviderConfig {
117- Path : "/tmp/test-zone.txt" ,
118- }
119-
120- domainFilter := endpoint .NewDomainFilter ([]string {})
121- provider := NewFileProvider (config , domainFilter )
122-
123- // ApplyChanges should return an error for read-only provider
124- ctx := context .Background ()
125- err := provider .ApplyChanges (ctx , nil )
126- assert .Error (t , err )
127- assert .Contains (t , err .Error (), "read-only" )
128- }
129-
130- func TestFileProvider_AdjustEndpoints (t * testing.T ) {
131- config := config.FileProviderConfig {
132- Path : "/tmp/test-zone.txt" ,
133- }
134-
135- domainFilter := endpoint .NewDomainFilter ([]string {})
136- provider := NewFileProvider (config , domainFilter )
137-
138- endpoints := []* endpoint.Endpoint {
139- {
140- DNSName : "test.example.com" ,
141- RecordType : "A" ,
142- Targets : []string {"192.168.1.1" },
143- },
144- }
145-
146- // AdjustEndpoints should return endpoints unchanged
147- adjusted , err := provider .AdjustEndpoints (endpoints )
148- assert .NoError (t , err )
149- assert .Equal (t , endpoints , adjusted )
150- }
151-
152117func TestFileProvider_MultipleMXRecords (t * testing.T ) {
153118 // Create a temporary zone file with multiple MX records
154119 zoneContent := `$ORIGIN example.com.
@@ -192,7 +157,7 @@ $TTL 3600
192157 // Find MX records
193158 var mxRecords []* endpoint.Endpoint
194159 for _ , record := range records {
195- if record .RecordType == "MX" && record .DNSName == "example.com" {
160+ if record .RecordType == "MX" && record .DNSName == testDomain {
196161 mxRecords = append (mxRecords , record )
197162 }
198163 }
0 commit comments