@@ -378,6 +378,25 @@ func TestEnsureUnstructuredMeta(t *testing.T) {
378378 }
379379 },
380380 },
381+ {
382+ name : "UID is preserved from cache object" ,
383+ cacheObjectMeta : metav1.ObjectMeta {UID : "cache-uid-123" , ResourceVersion : "1" , Annotations : map [string ]string {"a" : "b" }},
384+ localObjectMeta : metav1.ObjectMeta {UID : "local-uid-456" , ResourceVersion : "2" , Annotations : map [string ]string {"a" : "b" , "foo" : "bar" }},
385+ expectObjectMetaChanged : true ,
386+ validateCacheObjectMeta : func (t * testing.T , cacheObjectMeta , localObjectMeta metav1.ObjectMeta ) {
387+ t .Helper ()
388+
389+ expectedCacheObjectMeta := metav1.ObjectMeta {UID : "cache-uid-123" , ResourceVersion : "1" , Annotations : map [string ]string {"a" : "b" , "foo" : "bar" }}
390+ if ! reflect .DeepEqual (cacheObjectMeta , expectedCacheObjectMeta ) {
391+ t .Errorf ("received metadata differs from the expected one :\n %s" , cmp .Diff (cacheObjectMeta , expectedCacheObjectMeta ))
392+ }
393+
394+ expectedLocalObjectMeta := metav1.ObjectMeta {UID : "local-uid-456" , ResourceVersion : "2" , Annotations : map [string ]string {"a" : "b" , "foo" : "bar" }}
395+ if ! reflect .DeepEqual (localObjectMeta , expectedLocalObjectMeta ) {
396+ t .Errorf ("local object's metadata mustn't be changed, diff :\n %s" , cmp .Diff (localObjectMeta , expectedLocalObjectMeta ))
397+ }
398+ },
399+ },
381400 }
382401
383402 for _ , scenario := range scenarios {
0 commit comments