@@ -113,6 +113,93 @@ func TestResourceRecordSetItemMapper(t *testing.T) {
113
113
tests .Execute (t , item )
114
114
}
115
115
116
+ // TestConstructRecordFQDN tests the FQDN construction logic
117
+ // for various record name formats
118
+ func TestConstructRecordFQDN (t * testing.T ) {
119
+ type testCase struct {
120
+ name string
121
+ hostedZoneName string
122
+ recordName string
123
+ expectedFQDN string
124
+ description string
125
+ }
126
+
127
+ testCases := []testCase {
128
+ {
129
+ name : "simple_subdomain" ,
130
+ hostedZoneName : "example.com." ,
131
+ recordName : "www" ,
132
+ expectedFQDN : "www.example.com." ,
133
+ description : "Simple subdomain record" ,
134
+ },
135
+ {
136
+ name : "already_full_fqdn_with_trailing_dot" ,
137
+ hostedZoneName : "example.com." ,
138
+ recordName : "subdomain.example.com." ,
139
+ expectedFQDN : "subdomain.example.com." ,
140
+ description : "Record name already contains full FQDN with trailing dot" ,
141
+ },
142
+ {
143
+ name : "already_full_fqdn_without_trailing_dot" ,
144
+ hostedZoneName : "example.com." ,
145
+ recordName : "subdomain.example.com" ,
146
+ expectedFQDN : "subdomain.example.com" ,
147
+ description : "Record name already contains full FQDN without trailing dot" ,
148
+ },
149
+ {
150
+ name : "apex_record_matches_zone" ,
151
+ hostedZoneName : "example.com." ,
152
+ recordName : "example.com" ,
153
+ expectedFQDN : "example.com" ,
154
+ description : "Apex record where name matches zone FQDN (without trailing dot)" ,
155
+ },
156
+ {
157
+ name : "complex_subdomain_case" ,
158
+ hostedZoneName : "a2d-dev.tv." ,
159
+ recordName : "davidtest-other.a2d-dev.tv" ,
160
+ expectedFQDN : "davidtest-other.a2d-dev.tv" ,
161
+ description : "Complex case from the bug report - prevents double domain concatenation" ,
162
+ },
163
+ {
164
+ name : "nested_subdomain" ,
165
+ hostedZoneName : "example.com." ,
166
+ recordName : "deep.nested.subdomain" ,
167
+ expectedFQDN : "deep.nested.subdomain.example.com." ,
168
+ description : "Nested subdomain that needs zone appended" ,
169
+ },
170
+ {
171
+ name : "ns_record_with_full_domain" ,
172
+ hostedZoneName : "example.com." ,
173
+ recordName : "ns.example.com." ,
174
+ expectedFQDN : "ns.example.com." ,
175
+ description : "NS record with full domain (common pattern)" ,
176
+ },
177
+ {
178
+ name : "zone_without_trailing_dot" ,
179
+ hostedZoneName : "example.com" ,
180
+ recordName : "www" ,
181
+ expectedFQDN : "www.example.com" ,
182
+ description : "Hosted zone name without trailing dot" ,
183
+ },
184
+ {
185
+ name : "record_already_ends_with_zone_no_dot" ,
186
+ hostedZoneName : "example.com" ,
187
+ recordName : "subdomain.example.com" ,
188
+ expectedFQDN : "subdomain.example.com" ,
189
+ description : "Record already ends with zone name (no trailing dots)" ,
190
+ },
191
+ }
192
+
193
+ for _ , tc := range testCases {
194
+ t .Run (tc .name , func (t * testing.T ) {
195
+ result := constructRecordFQDN (tc .recordName , tc .hostedZoneName )
196
+ if result != tc .expectedFQDN {
197
+ t .Errorf ("Expected FQDN %q but got %q. %s" , tc .expectedFQDN , result , tc .description )
198
+ }
199
+ })
200
+ }
201
+ }
202
+
116
203
func TestNewRoute53ResourceRecordSetAdapter (t * testing.T ) {
117
204
client , account , region := route53GetAutoConfig (t )
118
205
0 commit comments