Skip to content

Commit

Permalink
Fix the fakeClient to include the relevant GVKs in the withStatusSubr…
Browse files Browse the repository at this point in the history
…esource 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
  • Loading branch information
aleskandro committed Jun 2, 2023
1 parent b971576 commit 710be50
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 4 additions & 1 deletion pkg/cloud/azure/actuators/machine/actuator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
tc.machine,
).Build()

m := tc.machine.DeepCopy()
if err := cs.Create(context.TODO(), m); err != nil {
Expand Down
5 changes: 3 additions & 2 deletions pkg/cloud/azure/actuators/machine_scope_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(machine).Build(),
}

scope, err := NewMachineScope(params)
Expand Down

0 comments on commit 710be50

Please sign in to comment.