@@ -726,6 +726,8 @@ func TestReconcileVM_EndToEnd(t *testing.T) {
726726 },
727727 }
728728
729+ task := newTask ()
730+
729731 // Round 0: no VM exists yet; CloneVM creates one and requeues for the task to complete.
730732 proxmoxClient .EXPECT ().GetReservableMemoryBytes (context .Background (), "node1" , int64 (100 )).Return (0 , nil ).Once ()
731733 proxmoxClient .EXPECT ().GetReservableMemoryBytes (context .Background (), "node2" , int64 (100 )).Return (^ uint64 (0 ), nil ).Once ()
@@ -739,7 +741,7 @@ func TestReconcileVM_EndToEnd(t *testing.T) {
739741 SnapName : "snap" ,
740742 Storage : "storage" ,
741743 Target : "node2" ,
742- }).Return (proxmox.VMCloneResponse {NewID : 123 , Task : newTask () }, nil ).Once ()
744+ }).Return (proxmox.VMCloneResponse {NewID : 123 , Task : task }, nil ).Once ()
743745
744746 result , err := ReconcileVM (context .Background (), machineScope )
745747 require .NoError (t , err )
@@ -754,10 +756,9 @@ func TestReconcileVM_EndToEnd(t *testing.T) {
754756 )
755757
756758 // Round 1: clone task complete; ConfigureVM sets VM options and requeues.
757- proxmoxClient .EXPECT ().GetTask (context .Background (), "result" ).Return (& lutherproxmox. Task { UPID : "result" , IsSuccessful : true } , nil ).Once ()
759+ proxmoxClient .EXPECT ().GetTask (context .Background (), "result" ).Return (task , nil ).Once ()
758760 proxmoxClient .EXPECT ().GetVM (context .Background (), "node2" , int64 (123 )).Return (vm , nil ).Once ()
759761
760- task := newTask ()
761762 expectedVMConfigureRequest := []interface {}{
762763 proxmox.VirtualMachineOption {Name : optionSockets , Value : * machineScope .ProxmoxMachine .Spec .NumSockets },
763764 proxmox.VirtualMachineOption {Name : optionCores , Value : * machineScope .ProxmoxMachine .Spec .NumCores },
@@ -782,7 +783,7 @@ func TestReconcileVM_EndToEnd(t *testing.T) {
782783 // Round 2: ConfigureVM task has completed; reconcileDisks resizes the boot volume,
783784 // then reconcileIPAddresses advances the state to WaitingForBootstrapData.
784785 // We're not mocking the entirety of a network setup.
785- proxmoxClient .EXPECT ().GetTask (context .Background (), "result" ).Return (& lutherproxmox. Task { UPID : "result" , IsSuccessful : true } , nil ).Once ()
786+ proxmoxClient .EXPECT ().GetTask (context .Background (), "result" ).Return (task , nil ).Once ()
786787 proxmoxClient .EXPECT ().GetVM (context .Background (), "node2" , int64 (123 )).Return (vm , nil ).Once ()
787788 proxmoxClient .EXPECT ().ResizeDisk (context .Background (), vm , "scsi0" , "50G" ).Return (nil , nil ).Once ()
788789
@@ -842,7 +843,7 @@ func TestReconcileVM_EndToEnd(t *testing.T) {
842843 vm .Status = lutherproxmox .StatusVirtualMachineRunning
843844 vm .QMPStatus = lutherproxmox .StatusVirtualMachineRunning
844845
845- proxmoxClient .EXPECT ().GetTask (context .Background (), "result" ).Return (& lutherproxmox. Task { UPID : "result" , IsSuccessful : true } , nil ).Once ()
846+ proxmoxClient .EXPECT ().GetTask (context .Background (), "result" ).Return (task , nil ).Once ()
846847 proxmoxClient .EXPECT ().GetVM (context .Background (), "node2" , int64 (123 )).Return (vm , nil ).Once ()
847848 proxmoxClient .EXPECT ().QemuAgentStatus (context .Background (), vm ).Return (nil ).Once ()
848849 proxmoxClient .EXPECT ().CloudInitStatus (context .Background (), vm ).Return (false , nil ).Once ()
0 commit comments