From f22d30fb87784d8b44b7e3ed0f5f3e1c41308449 Mon Sep 17 00:00:00 2001 From: Chun-Che Peng Date: Tue, 28 May 2024 22:28:44 -0700 Subject: [PATCH] adjust to new fake client behavior --- pkg/addon/addon_update_test.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/pkg/addon/addon_update_test.go b/pkg/addon/addon_update_test.go index c726ad75..3a8ce320 100644 --- a/pkg/addon/addon_update_test.go +++ b/pkg/addon/addon_update_test.go @@ -53,9 +53,6 @@ func TestUpdateAddonStatusLifecycleFromWorkflow(t *testing.T) { testNamespace := "default" testAddonName := "test-addon" - fakeCli := fake.NewClientBuilder().WithScheme(scheme).Build() - - updater := NewAddonUpdater(fakeRcdr, fakeCli, NewAddonVersionCacheClient(), ctrl.Log.WithName("test")) testAddon := &addonmgrv1alpha1.Addon{ ObjectMeta: metav1.ObjectMeta{ Name: testAddonName, @@ -74,6 +71,10 @@ func TestUpdateAddonStatusLifecycleFromWorkflow(t *testing.T) { Resources: []addonmgrv1alpha1.ObjectStatus{}, }, } + + fakeCli := fake.NewClientBuilder().WithScheme(scheme).WithStatusSubresource(testAddon).Build() + updater := NewAddonUpdater(fakeRcdr, fakeCli, NewAddonVersionCacheClient(), ctrl.Log.WithName("test")) + err := updater.client.Create(ctx, testAddon, &client.CreateOptions{}) g.Expect(err).ToNot(gomega.HaveOccurred()) @@ -167,9 +168,6 @@ func TestUpdateAddonStatusLifecycleFromWorkflow_DeleteFailed(t *testing.T) { testNamespace := "default" testAddonName := "test-addon" - fakeCli := fake.NewClientBuilder().WithScheme(scheme).Build() - - updater := NewAddonUpdater(fakeRcdr, fakeCli, NewAddonVersionCacheClient(), ctrl.Log.WithName("test")) testAddon := &addonmgrv1alpha1.Addon{ ObjectMeta: metav1.ObjectMeta{ Name: testAddonName, @@ -188,6 +186,10 @@ func TestUpdateAddonStatusLifecycleFromWorkflow_DeleteFailed(t *testing.T) { Resources: []addonmgrv1alpha1.ObjectStatus{}, }, } + + fakeCli := fake.NewClientBuilder().WithScheme(scheme).WithStatusSubresource(testAddon).Build() + updater := NewAddonUpdater(fakeRcdr, fakeCli, NewAddonVersionCacheClient(), ctrl.Log.WithName("test")) + err := updater.client.Create(ctx, testAddon, &client.CreateOptions{}) g.Expect(err).ToNot(gomega.HaveOccurred())