From 79e8b8f7330eb77c8421735bb6588a29cbd9342f Mon Sep 17 00:00:00 2001 From: avelichk Date: Fri, 17 Apr 2020 15:52:09 +0100 Subject: [PATCH 1/2] Remove suggestionRequest from updateSuggestion --- .../experiment/experiment_controller.go | 2 +- .../experiment/suggestion/fake/fake.go | 2 +- .../experiment/suggestion/suggestion.go | 4 ++-- pkg/mock/v1alpha3/experiment/suggestion/suggestion.go | 8 ++++---- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pkg/controller.v1alpha3/experiment/experiment_controller.go b/pkg/controller.v1alpha3/experiment/experiment_controller.go index dc55bb7197d..845b9dfed20 100644 --- a/pkg/controller.v1alpha3/experiment/experiment_controller.go +++ b/pkg/controller.v1alpha3/experiment/experiment_controller.go @@ -388,7 +388,7 @@ func (r *ReconcileExperiment) ReconcileSuggestions(instance *experimentsv1alpha3 } if suggestion.Spec.Requests != suggestionRequestsCount { suggestion.Spec.Requests = suggestionRequestsCount - if err := r.UpdateSuggestion(suggestion, suggestionRequestsCount); err != nil { + if err := r.UpdateSuggestion(suggestion); err != nil { return nil, err } } diff --git a/pkg/controller.v1alpha3/experiment/suggestion/fake/fake.go b/pkg/controller.v1alpha3/experiment/suggestion/fake/fake.go index 76db27bf3a0..fa05e7ad348 100644 --- a/pkg/controller.v1alpha3/experiment/suggestion/fake/fake.go +++ b/pkg/controller.v1alpha3/experiment/suggestion/fake/fake.go @@ -17,6 +17,6 @@ func (f *Fake) GetOrCreateSuggestion(instance *experimentsv1alpha3.Experiment, s return nil, nil } -func (f *Fake) UpdateSuggestion(suggestion *suggestionsv1alpha3.Suggestion, suggestionRequests int32) error { +func (f *Fake) UpdateSuggestion(suggestion *suggestionsv1alpha3.Suggestion) error { return nil } diff --git a/pkg/controller.v1alpha3/experiment/suggestion/suggestion.go b/pkg/controller.v1alpha3/experiment/suggestion/suggestion.go index de95d2a350f..f1ee8989c44 100644 --- a/pkg/controller.v1alpha3/experiment/suggestion/suggestion.go +++ b/pkg/controller.v1alpha3/experiment/suggestion/suggestion.go @@ -21,7 +21,7 @@ var log = logf.Log.WithName("experiment-suggestion-client") type Suggestion interface { GetOrCreateSuggestion(instance *experimentsv1alpha3.Experiment, suggestionRequests int32) (*suggestionsv1alpha3.Suggestion, error) - UpdateSuggestion(suggestion *suggestionsv1alpha3.Suggestion, suggestionRequests int32) error + UpdateSuggestion(suggestion *suggestionsv1alpha3.Suggestion) error } type General struct { @@ -79,7 +79,7 @@ func (g *General) createSuggestion(instance *experimentsv1alpha3.Experiment, sug return nil } -func (g *General) UpdateSuggestion(suggestion *suggestionsv1alpha3.Suggestion, suggestionRequests int32) error { +func (g *General) UpdateSuggestion(suggestion *suggestionsv1alpha3.Suggestion) error { if err := g.Update(context.TODO(), suggestion); err != nil { return err } diff --git a/pkg/mock/v1alpha3/experiment/suggestion/suggestion.go b/pkg/mock/v1alpha3/experiment/suggestion/suggestion.go index 6ea6a05a841..7dbffbf1de7 100644 --- a/pkg/mock/v1alpha3/experiment/suggestion/suggestion.go +++ b/pkg/mock/v1alpha3/experiment/suggestion/suggestion.go @@ -50,15 +50,15 @@ func (mr *MockSuggestionMockRecorder) GetOrCreateSuggestion(arg0, arg1 interface } // UpdateSuggestion mocks base method -func (m *MockSuggestion) UpdateSuggestion(arg0 *v1alpha30.Suggestion, arg1 int32) error { +func (m *MockSuggestion) UpdateSuggestion(arg0 *v1alpha30.Suggestion) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "UpdateSuggestion", arg0, arg1) + ret := m.ctrl.Call(m, "UpdateSuggestion", arg0) ret0, _ := ret[0].(error) return ret0 } // UpdateSuggestion indicates an expected call of UpdateSuggestion -func (mr *MockSuggestionMockRecorder) UpdateSuggestion(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockSuggestionMockRecorder) UpdateSuggestion(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateSuggestion", reflect.TypeOf((*MockSuggestion)(nil).UpdateSuggestion), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateSuggestion", reflect.TypeOf((*MockSuggestion)(nil).UpdateSuggestion), arg0) } From 069de488f70cd8d03c73d1dd0a4493b3b0eb1a48 Mon Sep 17 00:00:00 2001 From: avelichk Date: Fri, 17 Apr 2020 16:15:58 +0100 Subject: [PATCH 2/2] Fix test --- .../experiment/experiment_controller_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/controller.v1alpha3/experiment/experiment_controller_test.go b/pkg/controller.v1alpha3/experiment/experiment_controller_test.go index 46c80710067..2d3d094fdaf 100644 --- a/pkg/controller.v1alpha3/experiment/experiment_controller_test.go +++ b/pkg/controller.v1alpha3/experiment/experiment_controller_test.go @@ -133,7 +133,7 @@ func TestReconcileExperiment(t *testing.T) { }, }, }, nil).AnyTimes() - suggestion.EXPECT().UpdateSuggestion(gomock.Any(), gomock.Any()).Return(nil).AnyTimes() + suggestion.EXPECT().UpdateSuggestion(gomock.Any()).Return(nil).AnyTimes() mockCtrl3 := gomock.NewController(t) defer mockCtrl3.Finish() generator := manifestmock.NewMockGenerator(mockCtrl)