Skip to content

Commit 9c0f131

Browse files
committed
Update tests to be compatible with CR > v0.10.0
In controller-runtime v0.10.0, the client is updated to clean any stale data in the target object when performing any operation. This results in test failure for the code that constructs an object with both spec and status, and creates the object and updates status it with the same object. The fix is to set the status separately on the object before updating it. Refer: kubernetes-sigs/controller-runtime#1640 Signed-off-by: Sunny <[email protected]>
1 parent eeb7823 commit 9c0f131

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

controllers/update_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ Images:
232232
policy.Name = policyKey.Name
233233
policy.Namespace = policyKey.Namespace
234234
g.Expect(testEnv.Create(ctx, policy)).To(Succeed())
235+
policy.Status.LatestImage = "helloworld:v1.0.0"
235236
g.Expect(testEnv.Status().Update(ctx, policy)).To(Succeed())
236237

237238
// Format the expected message given the generated values
@@ -528,13 +529,11 @@ func TestImageUpdateAutomation_e2e(t *testing.T) {
528529
},
529530
},
530531
},
531-
Status: imagev1_reflect.ImagePolicyStatus{
532-
LatestImage: latestImage,
533-
},
534532
}
535533
policy.Name = policyKey.Name
536534
policy.Namespace = policyKey.Namespace
537535
g.Expect(testEnv.Create(ctx, policy)).To(Succeed())
536+
policy.Status.LatestImage = latestImage
538537
g.Expect(testEnv.Status().Update(ctx, policy)).To(Succeed())
539538
defer func() {
540539
g.Expect(testEnv.Delete(ctx, policy)).To(Succeed())

0 commit comments

Comments
 (0)