From dc3a9a23dcf72c8ca5cb7dc812b8890a0123f849 Mon Sep 17 00:00:00 2001 From: John Starich Date: Wed, 4 Aug 2021 21:25:46 -0500 Subject: [PATCH] Add test to check binding owner reference is not controller reference Signed-off-by: John Starich --- controllers/binding_controller_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/controllers/binding_controller_test.go b/controllers/binding_controller_test.go index 30fa6a65..fa4005e4 100644 --- a/controllers/binding_controller_test.go +++ b/controllers/binding_controller_test.go @@ -73,6 +73,22 @@ func TestBinding(t *testing.T) { // check binding is online require.Eventually(t, verifyStatus(ctx, t, binding.ObjectMeta, new(ibmcloudv1.Binding), bindingStateOnline), defaultWait, defaultTick) + { // check binding owner reference + var newBinding ibmcloudv1.Binding + require.NoError(t, getObject(ctx, binding.ObjectMeta, &newBinding)) + for i := range newBinding.OwnerReferences { + newBinding.OwnerReferences[i].UID = "" + } + assert.Equal(t, []metav1.OwnerReference{ + { + APIVersion: "ibmcloud.ibm.com/v1", + Kind: "Service", + Name: "test-translator-2", + Controller: nil, // controller must be nil. See https://github.com/IBM/cloud-operators/issues/222 + BlockOwnerDeletion: nil, + }, + }, newBinding.OwnerReferences) + } // check secret is created err = getObject(ctx, binding.ObjectMeta, &corev1.Secret{})