Skip to content

Commit bd63dc2

Browse files
committed
Test missing coverage in getProviderSpecificAnnotations
1 parent d077169 commit bd63dc2

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

source/source_test.go

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,57 @@ func TestGetProviderSpecificCloudflareAnnotations(t *testing.T) {
209209
t.Errorf("Cloudflare provider specific annotation %s is not set correctly to %v", tc.expectedKey, tc.expectedValue)
210210
})
211211
}
212+
213+
for _, tc := range []struct {
214+
title string
215+
annotations map[string]string
216+
expectedKey string
217+
expectedValue string
218+
}{
219+
{
220+
title: "Cloudflare comment is set",
221+
annotations: map[string]string{CloudflareRecordCommentKey: "test"},
222+
expectedKey: CloudflareRecordCommentKey,
223+
expectedValue: "test",
224+
},
225+
{
226+
title: "Cloudflare comment is set among other annotations",
227+
annotations: map[string]string{
228+
"random annotation 1": "random value 1",
229+
CloudflareRecordCommentKey: "test",
230+
"random annotation 2": "random value 2",
231+
},
232+
expectedKey: CloudflareRecordCommentKey,
233+
expectedValue: "test",
234+
},
235+
{
236+
title: "Cloudflare tags are set",
237+
annotations: map[string]string{CloudflareRecordTagsKey: "test1,test2"},
238+
expectedKey: CloudflareRecordTagsKey,
239+
expectedValue: "test1,test2",
240+
},
241+
{
242+
title: "Cloudflare tags are set among other annotations",
243+
annotations: map[string]string{
244+
"random annotation 1": "random value 1",
245+
CloudflareRecordTagsKey: "test1,test2",
246+
"random annotation 2": "random value 2",
247+
},
248+
expectedKey: CloudflareRecordTagsKey,
249+
expectedValue: "test1,test2",
250+
},
251+
} {
252+
t.Run(tc.title, func(t *testing.T) {
253+
providerSpecificAnnotations, _ := getProviderSpecificAnnotations(tc.annotations)
254+
for _, providerSpecificAnnotation := range providerSpecificAnnotations {
255+
if providerSpecificAnnotation.Name == tc.expectedKey {
256+
assert.Equal(t, tc.expectedValue, providerSpecificAnnotation.Value)
257+
return
258+
}
259+
}
260+
t.Errorf("Cloudflare provider specific annotation %s is not set correctly to %v", tc.expectedKey, tc.expectedValue)
261+
})
262+
}
212263
}
213264

214265
func TestGetProviderSpecificAliasAnnotations(t *testing.T) {

0 commit comments

Comments
 (0)