Skip to content

Commit

Permalink
VMClone, tests: Add a context
Browse files Browse the repository at this point in the history
Prepare a context "Failure to create a restore object",
to contain "restore already exists and vmclone is not updated yet".
This is done in preparation for adding a test in a following commit.

Signed-off-by: Orel Misan <[email protected]>
  • Loading branch information
orelmisan committed Dec 25, 2023
1 parent 2c5e56f commit a49e6b5
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions pkg/virt-controller/watch/clone/clone_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -493,24 +493,29 @@ var _ = Describe("Clone", func() {
controller.Execute()

})
It("when restore is already exists and vmclone is not update yet - should create restore failed", func() {
snapshot := createVirtualMachineSnapshot(sourceVM)
snapshot.Status.ReadyToUse = pointer.Bool(true)

restore := createVirtualMachineRestore(sourceVM, snapshot.Name)
Context("Failure to create a restore object", func() {
When("restore already exists and vmclone is not updated yet", func() {
It("should create restore failed", func() {
snapshot := createVirtualMachineSnapshot(sourceVM)
snapshot.Status.ReadyToUse = pointer.Bool(true)

vmClone.Status.SnapshotName = pointer.String(snapshot.Name)
restore := createVirtualMachineRestore(sourceVM, snapshot.Name)

vmClone.Status.Phase = clonev1alpha1.SnapshotInProgress
vmClone.Status.SnapshotName = pointer.String(snapshot.Name)

addVM(sourceVM)
addClone(vmClone)
addSnapshot(snapshot)
addRestore(restore)
expectRestoreCreateAlreadyExists(snapshot.Name, vmClone, restore.Name)
expectCloneUpdate(clonev1alpha1.RestoreInProgress)
vmClone.Status.Phase = clonev1alpha1.SnapshotInProgress

controller.Execute()
addVM(sourceVM)
addClone(vmClone)
addSnapshot(snapshot)
addRestore(restore)
expectRestoreCreateAlreadyExists(snapshot.Name, vmClone, restore.Name)
expectCloneUpdate(clonev1alpha1.RestoreInProgress)

controller.Execute()
})
})
})
})

Expand Down

0 comments on commit a49e6b5

Please sign in to comment.