@@ -272,8 +272,8 @@ var _ = Describe("Controllerutil", func() {
272
272
Controller : & t ,
273
273
BlockOwnerDeletion : & t ,
274
274
}))
275
-
276
275
Expect (controllerutil .RemoveControllerReference (dep , rs )).NotTo (HaveOccurred ())
276
+ Expect (len (rs .GetOwnerReferences ())).To (BeEquivalentTo (0 ))
277
277
})
278
278
It ("should fail and return an error if the length is less than 1" , func () {
279
279
rs := & appsv1.ReplicaSet {}
@@ -293,6 +293,21 @@ var _ = Describe("Controllerutil", func() {
293
293
Expect (controllerutil .SetControllerReference (dep , rs , scheme .Scheme )).NotTo (HaveOccurred ())
294
294
Expect (controllerutil .RemoveControllerReference (dep2 , rs )).To (HaveOccurred ())
295
295
})
296
+ It ("should only delete the controller reference and not the other owner references" , func () {
297
+ rs := & appsv1.ReplicaSet {}
298
+ dep := & extensionsv1beta1.Deployment {
299
+ ObjectMeta : metav1.ObjectMeta {Name : "foo" , UID : "foo-uid" },
300
+ }
301
+ dep2 := & extensionsv1beta1.Deployment {
302
+ ObjectMeta : metav1.ObjectMeta {Name : "bar" , UID : "bar-uid" },
303
+ }
304
+ Expect (controllerutil .SetControllerReference (dep , rs , scheme .Scheme )).NotTo (HaveOccurred ())
305
+ Expect (controllerutil .SetOwnerReference (dep2 , rs , scheme .Scheme )).NotTo (HaveOccurred ())
306
+ Expect (len (rs .GetOwnerReferences ())).To (BeEquivalentTo (2 ))
307
+ fmt .Printf ("owner %+v" , rs .GetOwnerReferences ())
308
+ Expect (controllerutil .RemoveControllerReference (dep , rs )).NotTo (HaveOccurred ())
309
+ Expect (len (rs .GetOwnerReferences ())).To (BeEquivalentTo (1 ))
310
+ })
296
311
297
312
})
298
313
0 commit comments