From 3876c3607a3ff26eeb7717fca3053d7a089a7cbe Mon Sep 17 00:00:00 2001 From: Michal Pryc Date: Wed, 13 Nov 2024 18:31:23 +0100 Subject: [PATCH] Add addNabDeletionTimestamp instead of using Spec field Added addNabDeletionTimestamp instead of using NAB spec field ForceDeleteBackup in the test. Signed-off-by: Michal Pryc --- internal/controller/nonadminbackup_controller_test.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/internal/controller/nonadminbackup_controller_test.go b/internal/controller/nonadminbackup_controller_test.go index c517719..feb7f96 100644 --- a/internal/controller/nonadminbackup_controller_test.go +++ b/internal/controller/nonadminbackup_controller_test.go @@ -51,6 +51,7 @@ type nonAdminBackupSingleReconcileScenario struct { uuidCreatedByReconcile bool uuidFromTestCase bool nonAdminBackupExpectedDeleted bool + addNabDeletionTimestamp bool } type nonAdminBackupFullReconcileScenario struct { @@ -250,7 +251,7 @@ var _ = ginkgo.Describe("Test single reconciles of NonAdminBackup Reconcile func } // We allow to have deleteNonAdminBackup and forceDeleteNonAdminBackup set to true at the same time - if scenario.nonAdminBackupSpec.ForceDeleteBackup { + if scenario.addNabDeletionTimestamp { // DeletionTimestamp is immutable and can only be set by the API server // We need to use Delete() instead of trying to set it directly gomega.Expect(k8sClient.Delete(ctx, nonAdminBackupAfterCreate)).To(gomega.Succeed()) @@ -481,7 +482,8 @@ var _ = ginkgo.Describe("Test single reconciles of NonAdminBackup Reconcile func result: reconcile.Result{Requeue: true}, }), ginkgo.Entry("When triggered by NonAdminBackup forceDeleteNonAdmin spec field with Finalizer set and NonAdminBackup phase Created without DeletionTimestamp, should trigger delete NonAdminBackup and requeue", nonAdminBackupSingleReconcileScenario{ - addFinalizer: true, + addFinalizer: true, + addNabDeletionTimestamp: false, nonAdminBackupSpec: nacv1alpha1.NonAdminBackupSpec{ ForceDeleteBackup: true, }, @@ -531,7 +533,8 @@ var _ = ginkgo.Describe("Test single reconciles of NonAdminBackup Reconcile func result: reconcile.Result{Requeue: true}, }), ginkgo.Entry("When triggered by NonAdminBackup forceDeleteNonAdmin spec field with Finalizer set, should delete NonAdminBackup and exit", nonAdminBackupSingleReconcileScenario{ - addFinalizer: true, + addFinalizer: true, + addNabDeletionTimestamp: true, nonAdminBackupSpec: nacv1alpha1.NonAdminBackupSpec{ BackupSpec: &velerov1.BackupSpec{}, ForceDeleteBackup: true,