@@ -395,3 +395,47 @@ func TestResolveAliases(t *testing.T) {
395
395
})
396
396
}
397
397
}
398
+
399
+ func TestGetMetadataPropertyWithMatchedKey (t * testing.T ) {
400
+ props := map [string ]string {
401
+ "key1" : "value1" ,
402
+ "key2" : "value2" ,
403
+ "key3" : "value3" ,
404
+ "emptyKey" : "" ,
405
+ }
406
+
407
+ t .Run ("Existing key" , func (t * testing.T ) {
408
+ key , val , ok := GetMetadataPropertyWithMatchedKey (props , "key1" , "key2" )
409
+ assert .True (t , ok )
410
+ assert .Equal (t , "key1" , key )
411
+ assert .Equal (t , "value1" , val )
412
+ })
413
+
414
+ t .Run ("Case-insensitive matching" , func (t * testing.T ) {
415
+ key , val , ok := GetMetadataPropertyWithMatchedKey (props , "KEY1" )
416
+ assert .True (t , ok )
417
+ assert .Equal (t , "KEY1" , key )
418
+ assert .Equal (t , "value1" , val )
419
+ })
420
+
421
+ t .Run ("Non-existing key" , func (t * testing.T ) {
422
+ key , val , ok := GetMetadataPropertyWithMatchedKey (props , "key4" )
423
+ assert .False (t , ok )
424
+ assert .Equal (t , "" , key )
425
+ assert .Equal (t , "" , val )
426
+ })
427
+
428
+ t .Run ("Empty properties" , func (t * testing.T ) {
429
+ key , val , ok := GetMetadataPropertyWithMatchedKey (nil , "key1" )
430
+ assert .False (t , ok )
431
+ assert .Equal (t , "" , key )
432
+ assert .Equal (t , "" , val )
433
+ })
434
+
435
+ t .Run ("Value is empty" , func (t * testing.T ) {
436
+ key , val , ok := GetMetadataPropertyWithMatchedKey (props , "EmptyKey" )
437
+ assert .True (t , ok )
438
+ assert .Equal (t , "EmptyKey" , key )
439
+ assert .Equal (t , "" , val )
440
+ })
441
+ }
0 commit comments