@@ -207,15 +207,16 @@ func TestGenerateVirtualMachineGroupAnnotations(t *testing.T) {
207207 }{
208208 {
209209 name : "Placement found for two distinct MDs" ,
210- vmg : & vmoprv1.VirtualMachineGroup {
211- ObjectMeta : baseVMG .ObjectMeta ,
212- Status : vmoprv1.VirtualMachineGroupStatus {
210+ vmg : func () * vmoprv1.VirtualMachineGroup {
211+ v := baseVMG .DeepCopy ()
212+ v . Status = vmoprv1.VirtualMachineGroupStatus {
213213 Members : []vmoprv1.VirtualMachineGroupMemberStatus {
214214 newVMGMemberStatus (vsmName1 , "VirtualMachine" , true , true , zoneA ),
215215 newVMGMemberStatus (vsmName2 , "VirtualMachine" , true , true , zoneB ),
216216 },
217- },
218- },
217+ }
218+ return v
219+ }(),
219220 machineDeployments : []string {mdName1 , mdName2 },
220221 initialClientObjects : []client.Object {vsm1 , vsm2 },
221222 expectedAnnotations : map [string ]string {
@@ -244,74 +245,79 @@ func TestGenerateVirtualMachineGroupAnnotations(t *testing.T) {
244245 },
245246 {
246247 name : "Skip if Member Kind is not VirtualMachine" ,
247- vmg : & vmoprv1.VirtualMachineGroup {
248- ObjectMeta : baseVMG .ObjectMeta ,
249- Status : vmoprv1.VirtualMachineGroupStatus {
248+ vmg : func () * vmoprv1.VirtualMachineGroup {
249+ v := baseVMG .DeepCopy ()
250+ v . Status = vmoprv1.VirtualMachineGroupStatus {
250251 Members : []vmoprv1.VirtualMachineGroupMemberStatus {
251252 newVMGMemberStatus ("VMG-1" , "VirtualMachineGroup" , true , true , "zone-x" ),
252253 },
253- },
254- },
254+ }
255+ return v
256+ }(),
255257 machineDeployments : []string {},
256258 initialClientObjects : []client.Object {},
257259 expectedAnnotations : map [string ]string {},
258260 wantErr : false ,
259261 },
260262 {
261263 name : "Skip if VSphereMachine Missing MachineDeployment Label" ,
262- vmg : & vmoprv1.VirtualMachineGroup {
263- ObjectMeta : baseVMG .ObjectMeta ,
264- Status : vmoprv1.VirtualMachineGroupStatus {
264+ vmg : func () * vmoprv1.VirtualMachineGroup {
265+ v := baseVMG .DeepCopy ()
266+ v . Status = vmoprv1.VirtualMachineGroupStatus {
265267 Members : []vmoprv1.VirtualMachineGroupMemberStatus {
266268 newVMGMemberStatus ("vsm-nolabel" , "VirtualMachine" , true , true , zoneA ),
267269 },
268- },
269- },
270+ }
271+ return v
272+ }(),
270273 machineDeployments : []string {mdName1 },
271274 initialClientObjects : []client.Object {vsmMissingLabel },
272275 expectedAnnotations : map [string ]string {},
273276 wantErr : false ,
274277 },
275278 {
276279 name : "Skip if VSphereMachine is Not Found in API" ,
277- vmg : & vmoprv1.VirtualMachineGroup {
278- ObjectMeta : baseVMG .ObjectMeta ,
279- Status : vmoprv1.VirtualMachineGroupStatus {
280+ vmg : func () * vmoprv1.VirtualMachineGroup {
281+ v := baseVMG .DeepCopy ()
282+ v . Status = vmoprv1.VirtualMachineGroupStatus {
280283 Members : []vmoprv1.VirtualMachineGroupMemberStatus {
281284 newVMGMemberStatus ("non-existent-vm" , "VirtualMachine" , true , true , zoneA ),
282285 },
283- },
284- },
286+ }
287+ return v
288+ }(),
285289 machineDeployments : []string {mdName1 },
286290 initialClientObjects : []client.Object {vsm1 },
287291 expectedAnnotations : map [string ]string {},
288292 wantErr : false ,
289293 },
290294 {
291295 name : "Skip if placement is nil" ,
292- vmg : & vmoprv1.VirtualMachineGroup {
293- ObjectMeta : baseVMG .ObjectMeta ,
294- Status : vmoprv1.VirtualMachineGroupStatus {
296+ vmg : func () * vmoprv1.VirtualMachineGroup {
297+ v := baseVMG .DeepCopy ()
298+ v . Status = vmoprv1.VirtualMachineGroupStatus {
295299 Members : []vmoprv1.VirtualMachineGroupMemberStatus {
296300 newVMGMemberStatus (vsmName1 , "VirtualMachine" , true , false , zoneA ),
297301 },
298- },
299- },
302+ }
303+ return v
304+ }(),
300305 machineDeployments : []string {mdName1 },
301306 initialClientObjects : []client.Object {vsm1 },
302307 expectedAnnotations : map [string ]string {},
303308 wantErr : false ,
304309 },
305310 {
306311 name : "Skip if Zone is empty string" ,
307- vmg : & vmoprv1.VirtualMachineGroup {
308- ObjectMeta : baseVMG .ObjectMeta ,
309- Status : vmoprv1.VirtualMachineGroupStatus {
312+ vmg : func () * vmoprv1.VirtualMachineGroup {
313+ v := baseVMG .DeepCopy ()
314+ v . Status = vmoprv1.VirtualMachineGroupStatus {
310315 Members : []vmoprv1.VirtualMachineGroupMemberStatus {
311316 newVMGMemberStatus (vsmName1 , "VirtualMachine" , true , true , "" ),
312317 },
313- },
314- },
318+ }
319+ return v
320+ }(),
315321 machineDeployments : []string {mdName1 },
316322 initialClientObjects : []client.Object {vsm1 },
317323 expectedAnnotations : map [string ]string {},
0 commit comments