diff --git a/controllers/controllers/workloads/cfbuild_controller_test.go b/controllers/controllers/workloads/cfbuild_controller_test.go index 8f0b574a0..57ff3d412 100644 --- a/controllers/controllers/workloads/cfbuild_controller_test.go +++ b/controllers/controllers/workloads/cfbuild_controller_test.go @@ -102,11 +102,14 @@ var _ = Describe("CFBuildReconciler Integration Tests", func() { It("cleans up older builds and droplets", func() { Eventually(func(g Gomega) { - g.Expect(buildCleaner.CleanCallCount()).To(BeNumerically(">", cleanCallCount)) + for i := cleanCallCount; i < buildCleaner.CleanCallCount(); i++ { + _, app := buildCleaner.CleanArgsForCall(i) + if app.Name == cfAppGUID && app.Namespace == cfSpace.Status.GUID { + return + } + } + g.Expect(errors.New("Clean() has not been invoked with expected args")).NotTo(HaveOccurred()) }).Should(Succeed()) - _, app := buildCleaner.CleanArgsForCall(buildCleaner.CleanCallCount() - 1) - Expect(app.Name).To(Equal(cfAppGUID)) - Expect(app.Namespace).To(Equal(cfSpace.Status.GUID)) }) It("reconciles to set the owner reference on the CFBuild", func() { diff --git a/controllers/controllers/workloads/cftask_controller_test.go b/controllers/controllers/workloads/cftask_controller_test.go index 7f1406ff9..846604504 100644 --- a/controllers/controllers/workloads/cftask_controller_test.go +++ b/controllers/controllers/workloads/cftask_controller_test.go @@ -12,7 +12,6 @@ import ( "github.com/onsi/gomega/gbytes" . "github.com/onsi/gomega/gstruct" corev1 "k8s.io/api/core/v1" - k8serrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/meta" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" @@ -359,7 +358,8 @@ var _ = Describe("CFTaskReconciler Integration Tests", func() { g.Expect(meta.IsStatusConditionTrue(cfTask.Status.Conditions, korifiv1alpha1.TaskInitializedConditionType)).To(BeTrue()) }).Should(Succeed()) - Expect(k8s.Patch(ctx, k8sClient, cfTask, func() { + Expect(k8s.Patch(ctx, adminClient, cfTask, func() { + cfTask.Annotations = map[string]string{"trigger-the": "reconciler"} meta.SetStatusCondition(&cfTask.Status.Conditions, metav1.Condition{ Type: korifiv1alpha1.TaskSucceededConditionType, Status: metav1.ConditionTrue, @@ -378,9 +378,9 @@ var _ = Describe("CFTaskReconciler Integration Tests", func() { task := new(korifiv1alpha1.CFTask) Eventually(func(g Gomega) { - err := k8sClient.Get(ctx, client.ObjectKeyFromObject(cfTask), task) - g.Expect(err).To(HaveOccurred(), "Task has not been deleted") - g.Expect(k8serrors.IsNotFound(err)).To(BeTrue()) + err := adminClient.Get(ctx, client.ObjectKeyFromObject(cfTask), task) + g.Expect(err).To(HaveOccurred(), "%#v", task.Status) + g.Expect(client.IgnoreNotFound(err)).NotTo(HaveOccurred()) }).Should(Succeed()) }) })