From 581dce54bdc48e432e5ce707450803c7efae923d Mon Sep 17 00:00:00 2001 From: Jonathan Tong Date: Mon, 13 Dec 2021 18:41:44 -0800 Subject: [PATCH] Cleanup client usage --- .../services/availabilitysets/availabilitysets.go | 6 +++--- .../availabilitysets/availabilitysets_test.go | 14 ++++++-------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/azure/services/availabilitysets/availabilitysets.go b/azure/services/availabilitysets/availabilitysets.go index 17416a9f21f..85c86b4259c 100644 --- a/azure/services/availabilitysets/availabilitysets.go +++ b/azure/services/availabilitysets/availabilitysets.go @@ -48,12 +48,12 @@ type Service struct { // New creates a new availability sets service. func New(scope AvailabilitySetScope, skuCache *resourceskus.Cache) *Service { - Client := NewClient(scope) + client := NewClient(scope) return &Service{ Scope: scope, - Client: Client, + Client: client, resourceSKUCache: skuCache, - Reconciler: async.New(scope, Client, Client), + Reconciler: async.New(scope, client, client), } } diff --git a/azure/services/availabilitysets/availabilitysets_test.go b/azure/services/availabilitysets/availabilitysets_test.go index 70c56d56cfc..7e87167e161 100644 --- a/azure/services/availabilitysets/availabilitysets_test.go +++ b/azure/services/availabilitysets/availabilitysets_test.go @@ -78,12 +78,12 @@ func TestReconcileAvailabilitySets(t *testing.T) { testcases := []struct { name string expectedError string - expect func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, m *mock_availabilitysets.MockClientMockRecorder, r *mock_async.MockReconcilerMockRecorder) + expect func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) }{ { name: "create or update availability set", expectedError: "", - expect: func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, m *mock_availabilitysets.MockClientMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.AvailabilitySetSpec().Return(&fakeSetSpec) r.CreateResource(gomockinternal.AContext(), &fakeSetSpec, serviceName).Return(nil, nil) s.UpdatePutStatus(infrav1.AvailabilitySetReadyCondition, serviceName, nil) @@ -92,7 +92,7 @@ func TestReconcileAvailabilitySets(t *testing.T) { { name: "noop if no availability set spec is found", expectedError: "", - expect: func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, m *mock_availabilitysets.MockClientMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.AvailabilitySetSpec().Return(nil) s.UpdatePutStatus(infrav1.AvailabilitySetReadyCondition, serviceName, nil) }, @@ -100,7 +100,7 @@ func TestReconcileAvailabilitySets(t *testing.T) { { name: "missing required value in availability set spec", expectedError: "some error with parameters", - expect: func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, m *mock_availabilitysets.MockClientMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.AvailabilitySetSpec().Return(&fakeSetSpecMissing) r.CreateResource(gomockinternal.AContext(), &fakeSetSpecMissing, serviceName).Return(nil, parameterError) s.UpdatePutStatus(infrav1.AvailabilitySetReadyCondition, serviceName, parameterError) @@ -109,7 +109,7 @@ func TestReconcileAvailabilitySets(t *testing.T) { { name: "error in creating availability set", expectedError: "#: Internal Server Error: StatusCode=500", - expect: func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, m *mock_availabilitysets.MockClientMockRecorder, r *mock_async.MockReconcilerMockRecorder) { + expect: func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.AvailabilitySetSpec().Return(&fakeSetSpec) r.CreateResource(gomockinternal.AContext(), &fakeSetSpec, serviceName).Return(nil, internalError) s.UpdatePutStatus(infrav1.AvailabilitySetReadyCondition, serviceName, internalError) @@ -125,14 +125,12 @@ func TestReconcileAvailabilitySets(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_availabilitysets.NewMockAvailabilitySetScope(mockCtrl) - clientMock := mock_availabilitysets.NewMockClient(mockCtrl) asyncMock := mock_async.NewMockReconciler(mockCtrl) - tc.expect(scopeMock.EXPECT(), clientMock.EXPECT(), asyncMock.EXPECT()) + tc.expect(scopeMock.EXPECT(), asyncMock.EXPECT()) s := &Service{ Scope: scopeMock, - Client: clientMock, Reconciler: asyncMock, }