diff --git a/controllers/dataprotection/storageprovider_controller_test.go b/controllers/dataprotection/storageprovider_controller_test.go index 0f963e7e160..a4f11ab1d59 100644 --- a/controllers/dataprotection/storageprovider_controller_test.go +++ b/controllers/dataprotection/storageprovider_controller_test.go @@ -132,9 +132,9 @@ var _ = Describe("StorageProvider controller", func() { g.ExpectWithOffset(1, val).Should(BeTrue()) } - reconcileNoError := func() { + reconcileNoError := func(g Gomega) { _, err := reconclier.Reconcile(testCtx.Ctx, reconcile.Request{NamespacedName: key}) - Expect(err).ToNot(HaveOccurred()) + g.ExpectWithOffset(1, err).ToNot(HaveOccurred()) } It("should reconcile a StorageProvider to Ready status if it doesn't specify csiDriverName", func() { @@ -143,7 +143,7 @@ var _ = Describe("StorageProvider controller", func() { By("checking status.phase and status.conditions") Eventually(func(g Gomega) { - reconcileNoError() + reconcileNoError(g) shouldReady(g, getProvider(g)) }).Should(Succeed()) }) @@ -155,7 +155,7 @@ var _ = Describe("StorageProvider controller", func() { By("checking status.phase and status.conditions") Eventually(func(g Gomega) { - reconcileNoError() + reconcileNoError(g) provider := getProvider(g) g.Expect(provider.Status.Phase).Should(BeEquivalentTo(dpv1alpha1.StorageProviderReady)) @@ -170,7 +170,7 @@ var _ = Describe("StorageProvider controller", func() { createStorageProviderSpec("csi2") By("checking status.phase, it should be NotReady because CSI driver is not installed yet") Eventually(func(g Gomega) { - reconcileNoError() + reconcileNoError(g) shouldNotReady(g, getProvider(g)) }).Should(Succeed()) @@ -178,7 +178,7 @@ var _ = Describe("StorageProvider controller", func() { createCSIDriverObjectSpec("csi2") By("checking status.phase, it should become Ready") Eventually(func(g Gomega) { - reconcileNoError() + reconcileNoError(g) shouldReady(g, getProvider(g)) }).Should(Succeed()) @@ -186,7 +186,7 @@ var _ = Describe("StorageProvider controller", func() { deleteCSIDriverObject("csi2") By("checking status.phase, it should become NotReady") Eventually(func(g Gomega) { - reconcileNoError() + reconcileNoError(g) shouldNotReady(g, getProvider(g)) }).Should(Succeed()) }) @@ -197,13 +197,13 @@ var _ = Describe("StorageProvider controller", func() { By("checking StorageProvider object") Eventually(testapps.CheckObj(&testCtx, key, func(g Gomega, provider *dpv1alpha1.StorageProvider) { - reconcileNoError() + reconcileNoError(g) g.Expect(provider.GetFinalizers()).To(ContainElement(dptypes.DataProtectionFinalizerName)) })).Should(Succeed()) By("deleting StorageProvider object") Eventually(func(g Gomega) { - reconcileNoError() + reconcileNoError(g) provider := &dpv1alpha1.StorageProvider{} err := testCtx.Cli.Get(ctx, key, provider) if apierrors.IsNotFound(err) { diff --git a/pkg/testutil/apps/common_util.go b/pkg/testutil/apps/common_util.go index 319cb288638..fa050abbdc1 100644 --- a/pkg/testutil/apps/common_util.go +++ b/pkg/testutil/apps/common_util.go @@ -20,6 +20,7 @@ along with this program. If not, see . package apps import ( + "encoding/json" "fmt" "reflect" "strings" @@ -333,7 +334,8 @@ func ClearResourcesWithRemoveFinalizerOption[T intctrlutil.Object, PT intctrluti for _, obj := range items { pobj := PT(&obj) if pobj.GetDeletionTimestamp().IsZero() { - panic("expected DeletionTimestamp is not nil") + d, _ := json.Marshal(pobj) + panic("expected DeletionTimestamp is not nil, obj: " + string(d)) } finalizers := pobj.GetFinalizers() if len(finalizers) > 0 {