From 08cffd76609624ebfe6ce074de39481f1d7580ac Mon Sep 17 00:00:00 2001 From: aleskandro Date: Fri, 2 Jun 2023 12:13:41 +0200 Subject: [PATCH] Fix the fakeClient to include the relevant GVKs in the withStatusSubresource set kubernetes-sigs/controller-runtime#2259 fixed the status handling of the fake client by adding a new WithStatusSubresource method to include the GVKs in a mock set used to distinguish whether an object being updated through the *fakeSubResourceClient.Patch method should be considered or throw errNotFound. Ref.: https://github.com/kubernetes-sigs/controller-runtime/pull/2259/files#diff-20ecedbf30721c01c33fb67d911da11c277e29990497a600d20cb0ec7215affdR387-R398 --- pkg/cloud/azure/actuators/machine/actuator_test.go | 5 ++++- pkg/cloud/azure/actuators/machine_scope_test.go | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pkg/cloud/azure/actuators/machine/actuator_test.go b/pkg/cloud/azure/actuators/machine/actuator_test.go index 7922ab0b5..01c88165e 100644 --- a/pkg/cloud/azure/actuators/machine/actuator_test.go +++ b/pkg/cloud/azure/actuators/machine/actuator_test.go @@ -658,7 +658,10 @@ func TestMachineEvents(t *testing.T) { for _, tc := range cases { t.Run(tc.name, func(t *testing.T) { - cs := controllerfake.NewFakeClientWithScheme(scheme.Scheme, tc.credSecret, infra) + cs := controllerfake.NewClientBuilder().WithScheme(scheme.Scheme). + WithObjects(tc.credSecret, infra).WithStatusSubresource( + &machinev1.Machine{}, + ).Build() m := tc.machine.DeepCopy() if err := cs.Create(context.TODO(), m); err != nil { diff --git a/pkg/cloud/azure/actuators/machine_scope_test.go b/pkg/cloud/azure/actuators/machine_scope_test.go index b00d8e4e9..728c35fe9 100644 --- a/pkg/cloud/azure/actuators/machine_scope_test.go +++ b/pkg/cloud/azure/actuators/machine_scope_test.go @@ -255,8 +255,9 @@ func TestPersistMachineScope(t *testing.T) { } params := MachineScopeParams{ - Machine: machine, - CoreClient: controllerfake.NewFakeClientWithScheme(scheme.Scheme, testCredentialSecret(), infra), + Machine: machine, + CoreClient: controllerfake.NewClientBuilder().WithScheme(scheme.Scheme). + WithObjects(testCredentialSecret(), infra).WithStatusSubresource(&machinev1.Machine{}).Build(), } scope, err := NewMachineScope(params)