Skip to content

Commit

Permalink
Add addNabDeletionTimestamp instead of using Spec field
Browse files Browse the repository at this point in the history
Added addNabDeletionTimestamp instead of using NAB spec
field ForceDeleteBackup in the test.

Signed-off-by: Michal Pryc <[email protected]>
  • Loading branch information
mpryc committed Nov 13, 2024
1 parent 7c370f7 commit 3876c36
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions internal/controller/nonadminbackup_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ type nonAdminBackupSingleReconcileScenario struct {
uuidCreatedByReconcile bool
uuidFromTestCase bool
nonAdminBackupExpectedDeleted bool
addNabDeletionTimestamp bool
}

type nonAdminBackupFullReconcileScenario struct {
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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,
},
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 3876c36

Please sign in to comment.