From 45fcf67c4d6001ee418435818373521e56dbd3ee Mon Sep 17 00:00:00 2001 From: Hidde Beydals Date: Mon, 11 Dec 2023 16:53:13 +0100 Subject: [PATCH] controller: address test flake As the Kubernetes client used in tests is cache backed, it can take a tiny bit of time for the client to actually notice the removal. Wrapping in `Eventually` should address this. Signed-off-by: Hidde Beydals --- internal/controller/helmrelease_controller_test.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/internal/controller/helmrelease_controller_test.go b/internal/controller/helmrelease_controller_test.go index 75fa2149a..6795570cb 100644 --- a/internal/controller/helmrelease_controller_test.go +++ b/internal/controller/helmrelease_controller_test.go @@ -852,12 +852,14 @@ func TestHelmReleaseReconciler_reconcileDelete(t *testing.T) { g.Expect(err).To(MatchError(helmdriver.ErrReleaseNotFound)) // Verify Helm chart has been removed. - err = testEnv.Get(context.TODO(), client.ObjectKey{ - Namespace: hc.Namespace, - Name: hc.Name, - }, &sourcev1b2.HelmChart{}) - g.Expect(err).To(HaveOccurred()) - g.Expect(apierrors.IsNotFound(err)).To(BeTrue()) + g.Eventually(func(g Gomega) { + err = testEnv.Get(context.TODO(), client.ObjectKey{ + Namespace: hc.Namespace, + Name: hc.Name, + }, &sourcev1b2.HelmChart{}) + g.Expect(err).To(HaveOccurred()) + g.Expect(apierrors.IsNotFound(err)).To(BeTrue()) + }) }) t.Run("removes finalizer for suspended resource with DeletionTimestamp", func(t *testing.T) {