diff --git a/pkg/services/vmoperator/vmopmachine_test.go b/pkg/services/vmoperator/vmopmachine_test.go index 7f1fc77b69..fc049788d1 100644 --- a/pkg/services/vmoperator/vmopmachine_test.go +++ b/pkg/services/vmoperator/vmopmachine_test.go @@ -547,16 +547,8 @@ var _ = Describe("VirtualMachine tests", func() { requeue, err = vmService.ReconcileNormal(ctx) // There is no GC behavior in the unit test environment, so simulate it vmService.deleteFunc = func(vm *vmoprv1.VirtualMachine) error { - if vm.GetFinalizers() == nil { - if err := ctx.Client.Delete(ctx, vm); err != nil { - return err - } - } else { - timeNow := metav1.Now() - vm.SetDeletionTimestamp(&timeNow) - if err := ctx.Client.Update(ctx, vm); err != nil { - return err - } + if err := ctx.Client.Delete(ctx, vm); err != nil { + return err } return nil } diff --git a/pkg/util/testutil.go b/pkg/util/testutil.go index 456f11cb12..ab3a298ad7 100644 --- a/pkg/util/testutil.go +++ b/pkg/util/testutil.go @@ -155,7 +155,10 @@ func CreateClusterContext(cluster *clusterv1.Cluster, vsphereCluster *infrav1.VS Context: goctx.Background(), Logger: klog.Background().WithName("controller-manager-logger"), Scheme: scheme, - Client: testclient.NewClientBuilder().WithScheme(scheme).Build(), + Client: testclient.NewClientBuilder().WithScheme(scheme).WithStatusSubresource( + &vmoprv1.VirtualMachineService{}, + &vmoprv1.VirtualMachine{}, + ).Build(), } // Build the controller context.