From 5c0b9e9c32bdb0da2ed45fa1092558773a80636b Mon Sep 17 00:00:00 2001 From: Zuhair AlSader Date: Wed, 20 Sep 2023 19:06:00 -0400 Subject: [PATCH] use uber gomock Signed-off-by: Zuhair AlSader --- Makefile | 4 ++-- go.mod | 2 +- go.sum | 5 ++--- mock/interface.go | 44 ++++++++++++++++++++++++-------------------- mock/mock_test.go | 2 +- 5 files changed, 30 insertions(+), 27 deletions(-) diff --git a/Makefile b/Makefile index 0864a2f9..0814b3cb 100644 --- a/Makefile +++ b/Makefile @@ -54,13 +54,13 @@ MOCKGEN ?= $(LOCALBIN)/mockgen CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen ## Tool Versions -MOCKGEN_VERSION ?= v1.6.0 +MOCKGEN_VERSION ?= v0.3.0 CONTROLLER_TOOLS_VERSION ?= v0.10.0 .PHONY: mockgen mockgen: $(MOCKGEN) ## Download mockgen locally if necessary. $(MOCKGEN): $(LOCALBIN) - test -s $(LOCALBIN)/mockgen || GOBIN=$(LOCALBIN) go install github.com/golang/mock/mockgen@$(MOCKGEN_VERSION) + test -s $(LOCALBIN)/mockgen || GOBIN=$(LOCALBIN) go install go.uber.org/mock/mockgen@$(MOCKGEN_VERSION) .PHONY: controller-gen controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary. diff --git a/go.mod b/go.mod index 10c575b5..143f7faf 100644 --- a/go.mod +++ b/go.mod @@ -3,9 +3,9 @@ module github.com/mittwald/go-helm-client go 1.20 require ( - github.com/golang/mock v1.6.0 github.com/pkg/errors v0.9.1 github.com/spf13/pflag v1.0.5 + go.uber.org/mock v0.3.0 helm.sh/helm/v3 v3.11.2 k8s.io/apiextensions-apiserver v0.26.3 k8s.io/apimachinery v0.27.1 diff --git a/go.sum b/go.sum index 28c6564d..aaa296cd 100644 --- a/go.sum +++ b/go.sum @@ -224,8 +224,6 @@ github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8= -github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= -github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -634,6 +632,8 @@ go.starlark.net v0.0.0-20221020143700-22309ac47eac h1:gBO5Qfcw5V9404yzsu2FEIsxK/ go.starlark.net v0.0.0-20221020143700-22309ac47eac/go.mod h1:kIVgS18CjmEC3PqMd5kaJSGEifyV/CeB9x506ZJ1Vbk= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +go.uber.org/mock v0.3.0 h1:3mUxI1No2/60yUYax92Pt8eNOEecx2D3lcXZh2NEZJo= +go.uber.org/mock v0.3.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= @@ -915,7 +915,6 @@ golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= -golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.7/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= diff --git a/mock/interface.go b/mock/interface.go index 0fdc07a9..e3f6a6fa 100644 --- a/mock/interface.go +++ b/mock/interface.go @@ -1,6 +1,10 @@ // Code generated by MockGen. DO NOT EDIT. // Source: interface.go - +// +// Generated by this command: +// +// mockgen -source=interface.go -package mockhelmclient -destination=./mock/interface.go -self_package=. Client +// // Package mockhelmclient is a generated GoMock package. package mockhelmclient @@ -8,8 +12,8 @@ import ( context "context" reflect "reflect" - gomock "github.com/golang/mock/gomock" helmclient "github.com/mittwald/go-helm-client" + gomock "go.uber.org/mock/gomock" action "helm.sh/helm/v3/pkg/action" chart "helm.sh/helm/v3/pkg/chart" release "helm.sh/helm/v3/pkg/release" @@ -48,7 +52,7 @@ func (m *MockClient) AddOrUpdateChartRepo(entry repo.Entry) error { } // AddOrUpdateChartRepo indicates an expected call of AddOrUpdateChartRepo. -func (mr *MockClientMockRecorder) AddOrUpdateChartRepo(entry interface{}) *gomock.Call { +func (mr *MockClientMockRecorder) AddOrUpdateChartRepo(entry any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddOrUpdateChartRepo", reflect.TypeOf((*MockClient)(nil).AddOrUpdateChartRepo), entry) } @@ -64,7 +68,7 @@ func (m *MockClient) GetChart(chartName string, chartPathOptions *action.ChartPa } // GetChart indicates an expected call of GetChart. -func (mr *MockClientMockRecorder) GetChart(chartName, chartPathOptions interface{}) *gomock.Call { +func (mr *MockClientMockRecorder) GetChart(chartName, chartPathOptions any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetChart", reflect.TypeOf((*MockClient)(nil).GetChart), chartName, chartPathOptions) } @@ -79,22 +83,22 @@ func (m *MockClient) GetRelease(name string) (*release.Release, error) { } // GetRelease indicates an expected call of GetRelease. -func (mr *MockClientMockRecorder) GetRelease(name interface{}) *gomock.Call { +func (mr *MockClientMockRecorder) GetRelease(name any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetRelease", reflect.TypeOf((*MockClient)(nil).GetRelease), name) } // GetReleaseValues mocks base method. -func (m *MockClient) GetReleaseValues(name string, allValues bool) (map[string]interface{}, error) { +func (m *MockClient) GetReleaseValues(name string, allValues bool) (map[string]any, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetReleaseValues", name, allValues) - ret0, _ := ret[0].(map[string]interface{}) + ret0, _ := ret[0].(map[string]any) ret1, _ := ret[1].(error) return ret0, ret1 } // GetReleaseValues indicates an expected call of GetReleaseValues. -func (mr *MockClientMockRecorder) GetReleaseValues(name, allValues interface{}) *gomock.Call { +func (mr *MockClientMockRecorder) GetReleaseValues(name, allValues any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetReleaseValues", reflect.TypeOf((*MockClient)(nil).GetReleaseValues), name, allValues) } @@ -109,7 +113,7 @@ func (m *MockClient) InstallChart(ctx context.Context, spec *helmclient.ChartSpe } // InstallChart indicates an expected call of InstallChart. -func (mr *MockClientMockRecorder) InstallChart(ctx, spec, opts interface{}) *gomock.Call { +func (mr *MockClientMockRecorder) InstallChart(ctx, spec, opts any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "InstallChart", reflect.TypeOf((*MockClient)(nil).InstallChart), ctx, spec, opts) } @@ -124,7 +128,7 @@ func (m *MockClient) InstallOrUpgradeChart(ctx context.Context, spec *helmclient } // InstallOrUpgradeChart indicates an expected call of InstallOrUpgradeChart. -func (mr *MockClientMockRecorder) InstallOrUpgradeChart(ctx, spec, opts interface{}) *gomock.Call { +func (mr *MockClientMockRecorder) InstallOrUpgradeChart(ctx, spec, opts any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "InstallOrUpgradeChart", reflect.TypeOf((*MockClient)(nil).InstallOrUpgradeChart), ctx, spec, opts) } @@ -138,7 +142,7 @@ func (m *MockClient) LintChart(spec *helmclient.ChartSpec) error { } // LintChart indicates an expected call of LintChart. -func (mr *MockClientMockRecorder) LintChart(spec interface{}) *gomock.Call { +func (mr *MockClientMockRecorder) LintChart(spec any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LintChart", reflect.TypeOf((*MockClient)(nil).LintChart), spec) } @@ -168,7 +172,7 @@ func (m *MockClient) ListReleaseHistory(name string, max int) ([]*release.Releas } // ListReleaseHistory indicates an expected call of ListReleaseHistory. -func (mr *MockClientMockRecorder) ListReleaseHistory(name, max interface{}) *gomock.Call { +func (mr *MockClientMockRecorder) ListReleaseHistory(name, max any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListReleaseHistory", reflect.TypeOf((*MockClient)(nil).ListReleaseHistory), name, max) } @@ -183,7 +187,7 @@ func (m *MockClient) ListReleasesByStateMask(arg0 action.ListStates) ([]*release } // ListReleasesByStateMask indicates an expected call of ListReleasesByStateMask. -func (mr *MockClientMockRecorder) ListReleasesByStateMask(arg0 interface{}) *gomock.Call { +func (mr *MockClientMockRecorder) ListReleasesByStateMask(arg0 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListReleasesByStateMask", reflect.TypeOf((*MockClient)(nil).ListReleasesByStateMask), arg0) } @@ -197,7 +201,7 @@ func (m *MockClient) RollbackRelease(spec *helmclient.ChartSpec) error { } // RollbackRelease indicates an expected call of RollbackRelease. -func (mr *MockClientMockRecorder) RollbackRelease(spec interface{}) *gomock.Call { +func (mr *MockClientMockRecorder) RollbackRelease(spec any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RollbackRelease", reflect.TypeOf((*MockClient)(nil).RollbackRelease), spec) } @@ -209,7 +213,7 @@ func (m *MockClient) SetDebugLog(debugLog action.DebugLog) { } // SetDebugLog indicates an expected call of SetDebugLog. -func (mr *MockClientMockRecorder) SetDebugLog(debugLog interface{}) *gomock.Call { +func (mr *MockClientMockRecorder) SetDebugLog(debugLog any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetDebugLog", reflect.TypeOf((*MockClient)(nil).SetDebugLog), debugLog) } @@ -224,7 +228,7 @@ func (m *MockClient) TemplateChart(spec *helmclient.ChartSpec, options *helmclie } // TemplateChart indicates an expected call of TemplateChart. -func (mr *MockClientMockRecorder) TemplateChart(spec, options interface{}) *gomock.Call { +func (mr *MockClientMockRecorder) TemplateChart(spec, options any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TemplateChart", reflect.TypeOf((*MockClient)(nil).TemplateChart), spec, options) } @@ -238,7 +242,7 @@ func (m *MockClient) UninstallRelease(spec *helmclient.ChartSpec) error { } // UninstallRelease indicates an expected call of UninstallRelease. -func (mr *MockClientMockRecorder) UninstallRelease(spec interface{}) *gomock.Call { +func (mr *MockClientMockRecorder) UninstallRelease(spec any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UninstallRelease", reflect.TypeOf((*MockClient)(nil).UninstallRelease), spec) } @@ -252,7 +256,7 @@ func (m *MockClient) UninstallReleaseByName(name string) error { } // UninstallReleaseByName indicates an expected call of UninstallReleaseByName. -func (mr *MockClientMockRecorder) UninstallReleaseByName(name interface{}) *gomock.Call { +func (mr *MockClientMockRecorder) UninstallReleaseByName(name any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UninstallReleaseByName", reflect.TypeOf((*MockClient)(nil).UninstallReleaseByName), name) } @@ -281,7 +285,7 @@ func (m *MockClient) UpgradeChart(ctx context.Context, spec *helmclient.ChartSpe } // UpgradeChart indicates an expected call of UpgradeChart. -func (mr *MockClientMockRecorder) UpgradeChart(ctx, spec, opts interface{}) *gomock.Call { +func (mr *MockClientMockRecorder) UpgradeChart(ctx, spec, opts any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpgradeChart", reflect.TypeOf((*MockClient)(nil).UpgradeChart), ctx, spec, opts) } @@ -318,7 +322,7 @@ func (m *MockRollBack) RollbackRelease(spec *helmclient.ChartSpec) error { } // RollbackRelease indicates an expected call of RollbackRelease. -func (mr *MockRollBackMockRecorder) RollbackRelease(spec interface{}) *gomock.Call { +func (mr *MockRollBackMockRecorder) RollbackRelease(spec any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RollbackRelease", reflect.TypeOf((*MockRollBack)(nil).RollbackRelease), spec) } diff --git a/mock/mock_test.go b/mock/mock_test.go index 6cdfca66..fefe468c 100644 --- a/mock/mock_test.go +++ b/mock/mock_test.go @@ -3,7 +3,7 @@ package mockhelmclient import ( "testing" - "github.com/golang/mock/gomock" + "go.uber.org/mock/gomock" "helm.sh/helm/v3/pkg/release" )