@@ -119,7 +119,7 @@ func TestEnsureVirtualMachine_CreateVM_FullOptions(t *testing.T) {
119119 machineScope .ProxmoxMachine .Spec .Pool = ptr .To ("pool" )
120120 machineScope .ProxmoxMachine .Spec .SnapName = ptr .To ("snap" )
121121 machineScope .ProxmoxMachine .Spec .Storage = ptr .To ("storage" )
122- machineScope .ProxmoxMachine .Spec .Target = ptr . To ( "node2" )
122+ machineScope .ProxmoxMachine .Spec .AllowedNodes = [] string { "node2" }
123123 expectedOptions := proxmox.VMCloneRequest {
124124 Node : "node1" ,
125125 Name : "test" ,
@@ -133,6 +133,7 @@ func TestEnsureVirtualMachine_CreateVM_FullOptions(t *testing.T) {
133133 }
134134 response := proxmox.VMCloneResponse {NewID : 123 , Task : newTask ()}
135135 proxmoxClient .EXPECT ().CloneVM (context .Background (), 123 , expectedOptions ).Return (response , nil ).Once ()
136+ proxmoxClient .EXPECT ().GetReservableMemoryBytes (context .Background (), "node2" , int64 (100 )).Return (^ uint64 (0 ), nil ).Once ()
136137
137138 requeue , err := ensureVirtualMachine (context .Background (), machineScope )
138139 require .NoError (t , err )
@@ -154,13 +155,14 @@ func TestEnsureVirtualMachine_CreateVM_FullOptions_TemplateSelector(t *testing.T
154155 },
155156 },
156157 }
158+
157159 machineScope .ProxmoxMachine .Spec .Description = ptr .To ("test vm" )
158160 machineScope .ProxmoxMachine .Spec .Format = ptr .To (infrav1 .TargetStorageFormatRaw )
159161 machineScope .ProxmoxMachine .Spec .Full = ptr .To (true )
160162 machineScope .ProxmoxMachine .Spec .Pool = ptr .To ("pool" )
161163 machineScope .ProxmoxMachine .Spec .SnapName = ptr .To ("snap" )
162164 machineScope .ProxmoxMachine .Spec .Storage = ptr .To ("storage" )
163- machineScope .ProxmoxMachine .Spec .Target = ptr . To ( " node2")
165+ machineScope .ProxmoxMachine .Spec .AllowedNodes = [] string { "node1" , " node2"}
164166 expectedOptions := proxmox.VMCloneRequest {
165167 Node : "node1" ,
166168 Name : "test" ,
@@ -175,10 +177,15 @@ func TestEnsureVirtualMachine_CreateVM_FullOptions_TemplateSelector(t *testing.T
175177
176178 // ResolutionPolicy is not set on the TemplateSelector in this test, so the default
177179 // policy is "exact". The vmservice must therefore pass "exact" to FindVMTemplateByTags.
178- proxmoxClient .EXPECT ().FindVMTemplateByTags (context .Background (), vmTemplateTags , "exact" ).Return ("node1" , 123 , nil ).Once ()
180+ proxmoxClient .EXPECT ().
181+ FindVMTemplateByTags (context .Background (), vmTemplateTags , string (infrav1 .TemplateMatchPolicyExact )).
182+ Return ("node1" , 123 , nil ).
183+ Once ()
179184
180185 response := proxmox.VMCloneResponse {NewID : 123 , Task : newTask ()}
181186 proxmoxClient .EXPECT ().CloneVM (context .Background (), 123 , expectedOptions ).Return (response , nil ).Once ()
187+ proxmoxClient .EXPECT ().GetReservableMemoryBytes (context .Background (), "node1" , int64 (100 )).Return (0 , nil ).Once ()
188+ proxmoxClient .EXPECT ().GetReservableMemoryBytes (context .Background (), "node2" , int64 (100 )).Return (^ uint64 (0 ), nil ).Once ()
182189
183190 requeue , err := ensureVirtualMachine (context .Background (), machineScope )
184191 require .NoError (t , err )
@@ -207,11 +214,10 @@ func TestEnsureVirtualMachine_CreateVM_FullOptions_TemplateSelector_VMTemplateNo
207214 machineScope .ProxmoxMachine .Spec .Pool = ptr .To ("pool" )
208215 machineScope .ProxmoxMachine .Spec .SnapName = ptr .To ("snap" )
209216 machineScope .ProxmoxMachine .Spec .Storage = ptr .To ("storage" )
210- machineScope .ProxmoxMachine .Spec .Target = ptr . To ( "node2" )
217+ machineScope .ProxmoxMachine .Spec .AllowedNodes = [] string { "node2" }
211218
212- // As above, no ResolutionPolicy is set on the TemplateSelector, so "exact" is the default
213- // and must be passed to FindVMTemplateByTags. In this scenario the template lookup fails.
214219 proxmoxClient .EXPECT ().FindVMTemplateByTags (context .Background (), vmTemplateTags , "exact" ).Return ("" , - 1 , goproxmox .ErrTemplateNotFound ).Once ()
220+ proxmoxClient .EXPECT ().GetReservableMemoryBytes (context .Background (), "node2" , int64 (100 )).Return (^ uint64 (0 ), nil ).Once ()
215221
216222 _ , err := createVM (ctx , machineScope )
217223
0 commit comments