diff --git a/controllers/cleaner_test.go b/controllers/cleaner_test.go index 2a37190b..36982450 100644 --- a/controllers/cleaner_test.go +++ b/controllers/cleaner_test.go @@ -29,7 +29,7 @@ func waitResourceToBeDelete(g gomega.Gomega, resource client.Object) { return k8sClient.Get(ctx, key, resource) }, cleanupTimeoutSeconds, interval).ShouldNot(gomega.Succeed()) - if resource.GetObjectKind().GroupVersionKind().Kind == infrav1.TerraformKind { + if _, ok := resource.(*infrav1.Terraform); ok { waitDefaultSecretsToBeDeletedForTerraform(g, resource) } } diff --git a/controllers/tc000201_auto_approve_with_disabled_drift_detection_test.go b/controllers/tc000201_auto_approve_with_disabled_drift_detection_test.go index 656e9d4a..4dbbab1c 100644 --- a/controllers/tc000201_auto_approve_with_disabled_drift_detection_test.go +++ b/controllers/tc000201_auto_approve_with_disabled_drift_detection_test.go @@ -1,5 +1,3 @@ -//go:build flaky - package controllers import ( @@ -44,7 +42,7 @@ func Test_000201_auto_approve_with_disabled_drift_detection(t *testing.T) { }, } g.Expect(k8sClient.Create(ctx, &testRepo)).Should(Succeed()) - defer func() { g.Expect(k8sClient.Delete(ctx, &testRepo)).Should(Succeed()) }() + defer waitResourceToBeDelete(g, &testRepo) By("setting the git repo status object, the URL, and the correct checksum") testRepo.Status = sourcev1.GitRepositoryStatus{ @@ -101,7 +99,7 @@ func Test_000201_auto_approve_with_disabled_drift_detection(t *testing.T) { }, } g.Expect(k8sClient.Create(ctx, &helloWorldTF)).Should(Succeed()) - defer func() { g.Expect(k8sClient.Delete(ctx, &helloWorldTF)).Should(Succeed()) }() + defer waitResourceToBeDelete(g, &helloWorldTF) By("checking that the hello world TF gets created") helloWorldTFKey := types.NamespacedName{Namespace: "flux-system", Name: terraformName}