From d01ed306381618062d86af3645bc64920c13bfb0 Mon Sep 17 00:00:00 2001 From: Aleksandr Tulskiy <62292054+tulzke@users.noreply.github.com> Date: Thu, 3 Oct 2024 21:48:24 +0300 Subject: [PATCH] deprecated reflect mode has been replaced with package mode (#207) It is impossible to create an mock for a generic interface via reflect mode, because it is impossible to compile a generic type without instantiation. This PR replaces the reflect mod for parsing using go/types. All exists mocks have been regenerated and the tests have been passed. But since this radically changes the behavior of reflect mode, I would be grateful if there are those who want to add additional test cases that I did not provide. We can also come up with another name instead of import mode. benefits: generation mocks for generic interfaces generation mocks for aliases to interfaces correct names for method arguments resolves https://github.com/uber-go/mock/issues/175 resolves https://github.com/uber-go/mock/issues/197 resolves https://github.com/uber-go/mock/issues/128 --------- Co-authored-by: Jacob Oaks --- README.md | 17 +- go.mod | 9 +- go.sum | 10 + gomock/internal/mock_gomock/mock_matcher.go | 8 +- mockgen/deprecated.go | 41 + .../tests/add_generate_directive/mock.go | 8 +- .../internal/tests/build_flags/directive.go | 6 + .../tests/build_flags/interfaces_1.go | 7 + .../tests/build_flags/interfaces_2.go | 7 + .../build_flags/mock1/interfaces_mock.go | 54 + .../build_flags/mock2/interfaces_mock.go | 52 + mockgen/internal/tests/extra_import/mock.go | 8 +- mockgen/internal/tests/generics/external.go | 1 + mockgen/internal/tests/generics/generics.go | 2 +- .../package_mode/mock_external_mock.go | 607 +++++++ .../tests/generics/package_mode/mock_test.go | 503 ++++++ .../tests/mock_name/mocks/post_service.go | 8 +- .../tests/mock_name/mocks/user_service.go | 8 +- .../internal/tests/package_mode/cars/cars.go | 44 + .../internal/tests/package_mode/fuel/fuel.go | 18 + .../internal/tests/package_mode/interfaces.go | 68 + .../tests/package_mode/mock/interfaces.go | 1458 +++++++++++++++++ .../package_mode/mock/interfaces_test.go | 41 + .../tests/sanitization/mockout/mock.go | 8 +- mockgen/mockgen.go | 24 +- mockgen/package_mode.go | 358 ++++ mockgen/package_mode_test.go | 360 ++++ mockgen/reflect.go | 256 --- sample/concurrent/mock/concurrent_mock.go | 8 +- sample/mock_user_test.go | 114 +- 30 files changed, 3749 insertions(+), 364 deletions(-) create mode 100644 mockgen/deprecated.go create mode 100644 mockgen/internal/tests/build_flags/directive.go create mode 100644 mockgen/internal/tests/build_flags/interfaces_1.go create mode 100644 mockgen/internal/tests/build_flags/interfaces_2.go create mode 100644 mockgen/internal/tests/build_flags/mock1/interfaces_mock.go create mode 100644 mockgen/internal/tests/build_flags/mock2/interfaces_mock.go create mode 100644 mockgen/internal/tests/generics/package_mode/mock_external_mock.go create mode 100644 mockgen/internal/tests/generics/package_mode/mock_test.go create mode 100644 mockgen/internal/tests/package_mode/cars/cars.go create mode 100644 mockgen/internal/tests/package_mode/fuel/fuel.go create mode 100644 mockgen/internal/tests/package_mode/interfaces.go create mode 100644 mockgen/internal/tests/package_mode/mock/interfaces.go create mode 100644 mockgen/internal/tests/package_mode/mock/interfaces_test.go create mode 100644 mockgen/package_mode.go create mode 100644 mockgen/package_mode_test.go delete mode 100644 mockgen/reflect.go diff --git a/README.md b/README.md index 7f8b414..b449eb2 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ export PATH=$PATH:$(go env GOPATH)/bin ## Running mockgen -`mockgen` has two modes of operation: source and reflect. +`mockgen` has two modes of operation: source and package. ### Source mode @@ -54,11 +54,10 @@ Example: mockgen -source=foo.go [other options] ``` -### Reflect mode +### Package mode -Reflect mode generates mock interfaces by building a program -that uses reflection to understand interfaces. It is enabled -by passing two non-flag arguments: an import path, and a +Package mode works by specifying the package and interface names. +It is enabled by passing two non-flag arguments: an import path, and a comma-separated list of symbols. You can use "." to refer to the current path's package. @@ -98,7 +97,7 @@ It supports the following flags: `foo=bar/baz.go`, where `bar/baz.go` is the source file and `foo` is the package name of that file used by the -source file. -- `-build_flags`: (reflect mode only) Flags passed verbatim to `go build`. +- `-build_flags`: (package mode only) Flags passed verbatim to `go list`. - `-mock_names`: A list of custom names for generated mocks. This is specified as a comma-separated list of elements of the form @@ -119,15 +118,11 @@ It supports the following flags: - `-debug_parser`: Print out parser results only. -- `-exec_only`: (reflect mode) If set, execute this reflection program. - -- `-prog_only`: (reflect mode) Only generate the reflection program; write it to stdout and exit. - - `-write_package_comment`: Writes package documentation comment (godoc) if true. (default true) - `-write_generate_directive`: Add //go:generate directive to regenerate the mock. (default false) -- `-write_source_comment`: Writes original file (source mode) or interface names (reflect mode) comment if true. (default true) +- `-write_source_comment`: Writes original file (source mode) or interface names (package mode) comment if true. (default true) - `-typed`: Generate Type-safe 'Return', 'Do', 'DoAndReturn' function. (default false) diff --git a/go.mod b/go.mod index 931eb94..f1ddbeb 100644 --- a/go.mod +++ b/go.mod @@ -3,8 +3,15 @@ module go.uber.org/mock go 1.22 require ( + github.com/stretchr/testify v1.9.0 golang.org/x/mod v0.18.0 golang.org/x/tools v0.22.0 ) -require github.com/yuin/goldmark v1.4.13 // indirect +require ( + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/yuin/goldmark v1.4.13 // indirect + golang.org/x/sync v0.7.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/go.sum b/go.sum index 0f174d4..e0222c2 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,9 @@ +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/yuin/goldmark v1.4.13 h1:fVcFKWvrslecOb/tg+Cc05dkeYx540o0FuFt3nUVDoE= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= golang.org/x/mod v0.18.0 h1:5+9lSbEzPSdWkH32vYPBwEpX8KwDbM52Ud9xBUvNlb0= @@ -6,3 +12,7 @@ golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/tools v0.22.0 h1:gqSGLZqv+AI9lIQzniJ0nZDRG5GBPsSi+DRNHWNz6yA= golang.org/x/tools v0.22.0/go.mod h1:aCwcsjqvq7Yqt6TNyX7QMU2enbQ/Gt0bo6krSeEri+c= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/gomock/internal/mock_gomock/mock_matcher.go b/gomock/internal/mock_gomock/mock_matcher.go index 2558913..fa1cd44 100644 --- a/gomock/internal/mock_gomock/mock_matcher.go +++ b/gomock/internal/mock_gomock/mock_matcher.go @@ -40,17 +40,17 @@ func (m *MockMatcher) EXPECT() *MockMatcherMockRecorder { } // Matches mocks base method. -func (m *MockMatcher) Matches(arg0 any) bool { +func (m *MockMatcher) Matches(x any) bool { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Matches", arg0) + ret := m.ctrl.Call(m, "Matches", x) ret0, _ := ret[0].(bool) return ret0 } // Matches indicates an expected call of Matches. -func (mr *MockMatcherMockRecorder) Matches(arg0 any) *gomock.Call { +func (mr *MockMatcherMockRecorder) Matches(x any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Matches", reflect.TypeOf((*MockMatcher)(nil).Matches), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Matches", reflect.TypeOf((*MockMatcher)(nil).Matches), x) } // String mocks base method. diff --git a/mockgen/deprecated.go b/mockgen/deprecated.go new file mode 100644 index 0000000..0b45a2e --- /dev/null +++ b/mockgen/deprecated.go @@ -0,0 +1,41 @@ +package main + +import ( + "flag" + "log" + "os" +) + +const ( + deprecatedFlagProgOnly = "prog_only" + deprecatedFlagExecOnly = "exec_only" +) + +var ( + _ = flag.Bool("prog_only", false, "DEPRECATED (reflect mode) Only generate the reflection program; write it to stdout and exit.") + _ = flag.String("exec_only", "", "DEPRECATED (reflect mode) If set, execute this reflection program.") +) + +// notifyAboutDeprecatedFlags prints a warning message for a deprecated flags if they are set. +func notifyAboutDeprecatedFlags() { + const resetColorPostfix = "\033[0m" + logger := initWarningLogger() + + flag.Visit(func(f *flag.Flag) { + switch f.Name { + case deprecatedFlagProgOnly: + logger.Println("The -prog_only flag is deprecated and has no effect.", resetColorPostfix) + case deprecatedFlagExecOnly: + logger.Println("The -exec_only flag is deprecated and has no effect.", resetColorPostfix) + } + }) +} + +func initWarningLogger() *log.Logger { + const ( + yellowColor = "\033[33m" + warningPrefix = yellowColor + "WARNING: " + ) + + return log.New(os.Stdout, warningPrefix, log.Ldate|log.Ltime) +} diff --git a/mockgen/internal/tests/add_generate_directive/mock.go b/mockgen/internal/tests/add_generate_directive/mock.go index 2cd489e..af68b01 100644 --- a/mockgen/internal/tests/add_generate_directive/mock.go +++ b/mockgen/internal/tests/add_generate_directive/mock.go @@ -42,13 +42,13 @@ func (m *MockFoo) EXPECT() *MockFooMockRecorder { } // Bar mocks base method. -func (m *MockFoo) Bar(arg0 []string, arg1 chan<- Message) { +func (m *MockFoo) Bar(channels []string, message chan<- Message) { m.ctrl.T.Helper() - m.ctrl.Call(m, "Bar", arg0, arg1) + m.ctrl.Call(m, "Bar", channels, message) } // Bar indicates an expected call of Bar. -func (mr *MockFooMockRecorder) Bar(arg0, arg1 any) *gomock.Call { +func (mr *MockFooMockRecorder) Bar(channels, message any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Bar", reflect.TypeOf((*MockFoo)(nil).Bar), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Bar", reflect.TypeOf((*MockFoo)(nil).Bar), channels, message) } diff --git a/mockgen/internal/tests/build_flags/directive.go b/mockgen/internal/tests/build_flags/directive.go new file mode 100644 index 0000000..4bfc9e9 --- /dev/null +++ b/mockgen/internal/tests/build_flags/directive.go @@ -0,0 +1,6 @@ +package build_flags + +// one build flag +//go:generate mockgen -destination=mock1/interfaces_mock.go -build_flags=-tags=tag1 . Interface +// multiple build flags +//go:generate mockgen -destination=mock2/interfaces_mock.go "-build_flags=-race -tags=tag2" . Interface diff --git a/mockgen/internal/tests/build_flags/interfaces_1.go b/mockgen/internal/tests/build_flags/interfaces_1.go new file mode 100644 index 0000000..e159cd6 --- /dev/null +++ b/mockgen/internal/tests/build_flags/interfaces_1.go @@ -0,0 +1,7 @@ +//go:build tag1 + +package build_flags + +type Interface interface { + HelloWorld() string +} diff --git a/mockgen/internal/tests/build_flags/interfaces_2.go b/mockgen/internal/tests/build_flags/interfaces_2.go new file mode 100644 index 0000000..5404cf7 --- /dev/null +++ b/mockgen/internal/tests/build_flags/interfaces_2.go @@ -0,0 +1,7 @@ +//go:build tag2 + +package build_flags + +type Interface interface { + Foo() +} diff --git a/mockgen/internal/tests/build_flags/mock1/interfaces_mock.go b/mockgen/internal/tests/build_flags/mock1/interfaces_mock.go new file mode 100644 index 0000000..7ca80bd --- /dev/null +++ b/mockgen/internal/tests/build_flags/mock1/interfaces_mock.go @@ -0,0 +1,54 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: go.uber.org/mock/mockgen/internal/tests/build_flags (interfaces: Interface) +// +// Generated by this command: +// +// mockgen -destination=mock1/interfaces_mock.go -build_flags=-tags=tag1 . Interface +// + +// Package mock_build_flags is a generated GoMock package. +package mock_build_flags + +import ( + reflect "reflect" + + gomock "go.uber.org/mock/gomock" +) + +// MockInterface is a mock of Interface interface. +type MockInterface struct { + ctrl *gomock.Controller + recorder *MockInterfaceMockRecorder + isgomock struct{} +} + +// MockInterfaceMockRecorder is the mock recorder for MockInterface. +type MockInterfaceMockRecorder struct { + mock *MockInterface +} + +// NewMockInterface creates a new mock instance. +func NewMockInterface(ctrl *gomock.Controller) *MockInterface { + mock := &MockInterface{ctrl: ctrl} + mock.recorder = &MockInterfaceMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockInterface) EXPECT() *MockInterfaceMockRecorder { + return m.recorder +} + +// HelloWorld mocks base method. +func (m *MockInterface) HelloWorld() string { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "HelloWorld") + ret0, _ := ret[0].(string) + return ret0 +} + +// HelloWorld indicates an expected call of HelloWorld. +func (mr *MockInterfaceMockRecorder) HelloWorld() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HelloWorld", reflect.TypeOf((*MockInterface)(nil).HelloWorld)) +} diff --git a/mockgen/internal/tests/build_flags/mock2/interfaces_mock.go b/mockgen/internal/tests/build_flags/mock2/interfaces_mock.go new file mode 100644 index 0000000..4f21187 --- /dev/null +++ b/mockgen/internal/tests/build_flags/mock2/interfaces_mock.go @@ -0,0 +1,52 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: go.uber.org/mock/mockgen/internal/tests/build_flags (interfaces: Interface) +// +// Generated by this command: +// +// mockgen -destination=mock2/interfaces_mock.go -build_flags=-race -tags=tag2 . Interface +// + +// Package mock_build_flags is a generated GoMock package. +package mock_build_flags + +import ( + reflect "reflect" + + gomock "go.uber.org/mock/gomock" +) + +// MockInterface is a mock of Interface interface. +type MockInterface struct { + ctrl *gomock.Controller + recorder *MockInterfaceMockRecorder + isgomock struct{} +} + +// MockInterfaceMockRecorder is the mock recorder for MockInterface. +type MockInterfaceMockRecorder struct { + mock *MockInterface +} + +// NewMockInterface creates a new mock instance. +func NewMockInterface(ctrl *gomock.Controller) *MockInterface { + mock := &MockInterface{ctrl: ctrl} + mock.recorder = &MockInterfaceMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockInterface) EXPECT() *MockInterfaceMockRecorder { + return m.recorder +} + +// Foo mocks base method. +func (m *MockInterface) Foo() { + m.ctrl.T.Helper() + m.ctrl.Call(m, "Foo") +} + +// Foo indicates an expected call of Foo. +func (mr *MockInterfaceMockRecorder) Foo() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Foo", reflect.TypeOf((*MockInterface)(nil).Foo)) +} diff --git a/mockgen/internal/tests/extra_import/mock.go b/mockgen/internal/tests/extra_import/mock.go index da611a8..b395d7c 100644 --- a/mockgen/internal/tests/extra_import/mock.go +++ b/mockgen/internal/tests/extra_import/mock.go @@ -40,13 +40,13 @@ func (m *MockFoo) EXPECT() *MockFooMockRecorder { } // Bar mocks base method. -func (m *MockFoo) Bar(arg0 []string, arg1 chan<- Message) { +func (m *MockFoo) Bar(channels []string, message chan<- Message) { m.ctrl.T.Helper() - m.ctrl.Call(m, "Bar", arg0, arg1) + m.ctrl.Call(m, "Bar", channels, message) } // Bar indicates an expected call of Bar. -func (mr *MockFooMockRecorder) Bar(arg0, arg1 any) *gomock.Call { +func (mr *MockFooMockRecorder) Bar(channels, message any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Bar", reflect.TypeOf((*MockFoo)(nil).Bar), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Bar", reflect.TypeOf((*MockFoo)(nil).Bar), channels, message) } diff --git a/mockgen/internal/tests/generics/external.go b/mockgen/internal/tests/generics/external.go index a12c39f..443d565 100644 --- a/mockgen/internal/tests/generics/external.go +++ b/mockgen/internal/tests/generics/external.go @@ -9,6 +9,7 @@ import ( ) //go:generate mockgen --source=external.go --destination=source/mock_external_mock.go --package source +//go:generate mockgen --destination=package_mode/mock_external_mock.go -package=package_mode . ExternalConstraint,EmbeddingIface,Generator,Group type ExternalConstraint[I constraints.Integer, F any] interface { One(string) string diff --git a/mockgen/internal/tests/generics/generics.go b/mockgen/internal/tests/generics/generics.go index db0c49e..5ff70f8 100644 --- a/mockgen/internal/tests/generics/generics.go +++ b/mockgen/internal/tests/generics/generics.go @@ -6,7 +6,7 @@ import ( ) //go:generate mockgen --source=generics.go --destination=source/mock_generics_mock.go --package source -////go:generate mockgen --destination=reflect/mock_test.go --package reflect . Bar,Bar2 +//go:generate mockgen --destination=package_mode/mock_test.go --package=package_mode . Bar,Universe,MilkyWay,SolarSystem,Earth,Water type Bar[T any, R any] interface { One(string) string diff --git a/mockgen/internal/tests/generics/package_mode/mock_external_mock.go b/mockgen/internal/tests/generics/package_mode/mock_external_mock.go new file mode 100644 index 0000000..61fda78 --- /dev/null +++ b/mockgen/internal/tests/generics/package_mode/mock_external_mock.go @@ -0,0 +1,607 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: go.uber.org/mock/mockgen/internal/tests/generics (interfaces: ExternalConstraint,EmbeddingIface,Generator,Group) +// +// Generated by this command: +// +// mockgen --destination=package_mode/mock_external_mock.go -package=package_mode . ExternalConstraint,EmbeddingIface,Generator,Group +// + +// Package package_mode is a generated GoMock package. +package package_mode + +import ( + context "context" + reflect "reflect" + + gomock "go.uber.org/mock/gomock" + generics "go.uber.org/mock/mockgen/internal/tests/generics" + other "go.uber.org/mock/mockgen/internal/tests/generics/other" + constraints "golang.org/x/exp/constraints" +) + +// MockExternalConstraint is a mock of ExternalConstraint interface. +type MockExternalConstraint[I constraints.Integer, F any] struct { + ctrl *gomock.Controller + recorder *MockExternalConstraintMockRecorder[I, F] + isgomock struct{} +} + +// MockExternalConstraintMockRecorder is the mock recorder for MockExternalConstraint. +type MockExternalConstraintMockRecorder[I constraints.Integer, F any] struct { + mock *MockExternalConstraint[I, F] +} + +// NewMockExternalConstraint creates a new mock instance. +func NewMockExternalConstraint[I constraints.Integer, F any](ctrl *gomock.Controller) *MockExternalConstraint[I, F] { + mock := &MockExternalConstraint[I, F]{ctrl: ctrl} + mock.recorder = &MockExternalConstraintMockRecorder[I, F]{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockExternalConstraint[I, F]) EXPECT() *MockExternalConstraintMockRecorder[I, F] { + return m.recorder +} + +// Eight mocks base method. +func (m *MockExternalConstraint[I, F]) Eight(arg0 F) other.Two[I, F] { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Eight", arg0) + ret0, _ := ret[0].(other.Two[I, F]) + return ret0 +} + +// Eight indicates an expected call of Eight. +func (mr *MockExternalConstraintMockRecorder[I, F]) Eight(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Eight", reflect.TypeOf((*MockExternalConstraint[I, F])(nil).Eight), arg0) +} + +// Eleven mocks base method. +func (m *MockExternalConstraint[I, F]) Eleven() map[string]I { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Eleven") + ret0, _ := ret[0].(map[string]I) + return ret0 +} + +// Eleven indicates an expected call of Eleven. +func (mr *MockExternalConstraintMockRecorder[I, F]) Eleven() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Eleven", reflect.TypeOf((*MockExternalConstraint[I, F])(nil).Eleven)) +} + +// Five mocks base method. +func (m *MockExternalConstraint[I, F]) Five(arg0 I) generics.Baz[F] { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Five", arg0) + ret0, _ := ret[0].(generics.Baz[F]) + return ret0 +} + +// Five indicates an expected call of Five. +func (mr *MockExternalConstraintMockRecorder[I, F]) Five(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Five", reflect.TypeOf((*MockExternalConstraint[I, F])(nil).Five), arg0) +} + +// Four mocks base method. +func (m *MockExternalConstraint[I, F]) Four(arg0 I) generics.Foo[I, F] { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Four", arg0) + ret0, _ := ret[0].(generics.Foo[I, F]) + return ret0 +} + +// Four indicates an expected call of Four. +func (mr *MockExternalConstraintMockRecorder[I, F]) Four(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Four", reflect.TypeOf((*MockExternalConstraint[I, F])(nil).Four), arg0) +} + +// Nine mocks base method. +func (m *MockExternalConstraint[I, F]) Nine(arg0 generics.Iface[I]) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "Nine", arg0) +} + +// Nine indicates an expected call of Nine. +func (mr *MockExternalConstraintMockRecorder[I, F]) Nine(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Nine", reflect.TypeOf((*MockExternalConstraint[I, F])(nil).Nine), arg0) +} + +// One mocks base method. +func (m *MockExternalConstraint[I, F]) One(arg0 string) string { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "One", arg0) + ret0, _ := ret[0].(string) + return ret0 +} + +// One indicates an expected call of One. +func (mr *MockExternalConstraintMockRecorder[I, F]) One(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "One", reflect.TypeOf((*MockExternalConstraint[I, F])(nil).One), arg0) +} + +// Seven mocks base method. +func (m *MockExternalConstraint[I, F]) Seven(arg0 I) other.One[I] { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Seven", arg0) + ret0, _ := ret[0].(other.One[I]) + return ret0 +} + +// Seven indicates an expected call of Seven. +func (mr *MockExternalConstraintMockRecorder[I, F]) Seven(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Seven", reflect.TypeOf((*MockExternalConstraint[I, F])(nil).Seven), arg0) +} + +// Six mocks base method. +func (m *MockExternalConstraint[I, F]) Six(arg0 I) *generics.Baz[F] { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Six", arg0) + ret0, _ := ret[0].(*generics.Baz[F]) + return ret0 +} + +// Six indicates an expected call of Six. +func (mr *MockExternalConstraintMockRecorder[I, F]) Six(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Six", reflect.TypeOf((*MockExternalConstraint[I, F])(nil).Six), arg0) +} + +// Ten mocks base method. +func (m *MockExternalConstraint[I, F]) Ten(arg0 *I) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "Ten", arg0) +} + +// Ten indicates an expected call of Ten. +func (mr *MockExternalConstraintMockRecorder[I, F]) Ten(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Ten", reflect.TypeOf((*MockExternalConstraint[I, F])(nil).Ten), arg0) +} + +// Thirteen mocks base method. +func (m *MockExternalConstraint[I, F]) Thirteen(arg0 ...I) *F { + m.ctrl.T.Helper() + varargs := []any{} + for _, a := range arg0 { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Thirteen", varargs...) + ret0, _ := ret[0].(*F) + return ret0 +} + +// Thirteen indicates an expected call of Thirteen. +func (mr *MockExternalConstraintMockRecorder[I, F]) Thirteen(arg0 ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Thirteen", reflect.TypeOf((*MockExternalConstraint[I, F])(nil).Thirteen), arg0...) +} + +// Three mocks base method. +func (m *MockExternalConstraint[I, F]) Three(arg0 I) F { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Three", arg0) + ret0, _ := ret[0].(F) + return ret0 +} + +// Three indicates an expected call of Three. +func (mr *MockExternalConstraintMockRecorder[I, F]) Three(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Three", reflect.TypeOf((*MockExternalConstraint[I, F])(nil).Three), arg0) +} + +// Twelve mocks base method. +func (m *MockExternalConstraint[I, F]) Twelve(ctx context.Context) <-chan []I { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Twelve", ctx) + ret0, _ := ret[0].(<-chan []I) + return ret0 +} + +// Twelve indicates an expected call of Twelve. +func (mr *MockExternalConstraintMockRecorder[I, F]) Twelve(ctx any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Twelve", reflect.TypeOf((*MockExternalConstraint[I, F])(nil).Twelve), ctx) +} + +// Two mocks base method. +func (m *MockExternalConstraint[I, F]) Two(arg0 I) string { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Two", arg0) + ret0, _ := ret[0].(string) + return ret0 +} + +// Two indicates an expected call of Two. +func (mr *MockExternalConstraintMockRecorder[I, F]) Two(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Two", reflect.TypeOf((*MockExternalConstraint[I, F])(nil).Two), arg0) +} + +// MockEmbeddingIface is a mock of EmbeddingIface interface. +type MockEmbeddingIface[T constraints.Integer, R constraints.Float] struct { + ctrl *gomock.Controller + recorder *MockEmbeddingIfaceMockRecorder[T, R] + isgomock struct{} +} + +// MockEmbeddingIfaceMockRecorder is the mock recorder for MockEmbeddingIface. +type MockEmbeddingIfaceMockRecorder[T constraints.Integer, R constraints.Float] struct { + mock *MockEmbeddingIface[T, R] +} + +// NewMockEmbeddingIface creates a new mock instance. +func NewMockEmbeddingIface[T constraints.Integer, R constraints.Float](ctrl *gomock.Controller) *MockEmbeddingIface[T, R] { + mock := &MockEmbeddingIface[T, R]{ctrl: ctrl} + mock.recorder = &MockEmbeddingIfaceMockRecorder[T, R]{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockEmbeddingIface[T, R]) EXPECT() *MockEmbeddingIfaceMockRecorder[T, R] { + return m.recorder +} + +// Eight mocks base method. +func (m *MockEmbeddingIface[T, R]) Eight(arg0 R) other.Two[T, R] { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Eight", arg0) + ret0, _ := ret[0].(other.Two[T, R]) + return ret0 +} + +// Eight indicates an expected call of Eight. +func (mr *MockEmbeddingIfaceMockRecorder[T, R]) Eight(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Eight", reflect.TypeOf((*MockEmbeddingIface[T, R])(nil).Eight), arg0) +} + +// Eleven mocks base method. +func (m *MockEmbeddingIface[T, R]) Eleven() map[string]T { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Eleven") + ret0, _ := ret[0].(map[string]T) + return ret0 +} + +// Eleven indicates an expected call of Eleven. +func (mr *MockEmbeddingIfaceMockRecorder[T, R]) Eleven() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Eleven", reflect.TypeOf((*MockEmbeddingIface[T, R])(nil).Eleven)) +} + +// First mocks base method. +func (m *MockEmbeddingIface[T, R]) First() R { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "First") + ret0, _ := ret[0].(R) + return ret0 +} + +// First indicates an expected call of First. +func (mr *MockEmbeddingIfaceMockRecorder[T, R]) First() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "First", reflect.TypeOf((*MockEmbeddingIface[T, R])(nil).First)) +} + +// Five mocks base method. +func (m *MockEmbeddingIface[T, R]) Five(arg0 T) generics.Baz[R] { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Five", arg0) + ret0, _ := ret[0].(generics.Baz[R]) + return ret0 +} + +// Five indicates an expected call of Five. +func (mr *MockEmbeddingIfaceMockRecorder[T, R]) Five(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Five", reflect.TypeOf((*MockEmbeddingIface[T, R])(nil).Five), arg0) +} + +// Four mocks base method. +func (m *MockEmbeddingIface[T, R]) Four(arg0 T) generics.Foo[T, R] { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Four", arg0) + ret0, _ := ret[0].(generics.Foo[T, R]) + return ret0 +} + +// Four indicates an expected call of Four. +func (mr *MockEmbeddingIfaceMockRecorder[T, R]) Four(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Four", reflect.TypeOf((*MockEmbeddingIface[T, R])(nil).Four), arg0) +} + +// Fourth mocks base method. +func (m *MockEmbeddingIface[T, R]) Fourth() generics.Generator[T] { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Fourth") + ret0, _ := ret[0].(generics.Generator[T]) + return ret0 +} + +// Fourth indicates an expected call of Fourth. +func (mr *MockEmbeddingIfaceMockRecorder[T, R]) Fourth() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Fourth", reflect.TypeOf((*MockEmbeddingIface[T, R])(nil).Fourth)) +} + +// Generate mocks base method. +func (m *MockEmbeddingIface[T, R]) Generate() R { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Generate") + ret0, _ := ret[0].(R) + return ret0 +} + +// Generate indicates an expected call of Generate. +func (mr *MockEmbeddingIfaceMockRecorder[T, R]) Generate() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Generate", reflect.TypeOf((*MockEmbeddingIface[T, R])(nil).Generate)) +} + +// Nine mocks base method. +func (m *MockEmbeddingIface[T, R]) Nine(arg0 generics.Iface[T]) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "Nine", arg0) +} + +// Nine indicates an expected call of Nine. +func (mr *MockEmbeddingIfaceMockRecorder[T, R]) Nine(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Nine", reflect.TypeOf((*MockEmbeddingIface[T, R])(nil).Nine), arg0) +} + +// One mocks base method. +func (m *MockEmbeddingIface[T, R]) One(arg0 string) string { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "One", arg0) + ret0, _ := ret[0].(string) + return ret0 +} + +// One indicates an expected call of One. +func (mr *MockEmbeddingIfaceMockRecorder[T, R]) One(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "One", reflect.TypeOf((*MockEmbeddingIface[T, R])(nil).One), arg0) +} + +// Read mocks base method. +func (m *MockEmbeddingIface[T, R]) Read(p []byte) (int, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Read", p) + ret0, _ := ret[0].(int) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Read indicates an expected call of Read. +func (mr *MockEmbeddingIfaceMockRecorder[T, R]) Read(p any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Read", reflect.TypeOf((*MockEmbeddingIface[T, R])(nil).Read), p) +} + +// Second mocks base method. +func (m *MockEmbeddingIface[T, R]) Second() generics.StructType { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Second") + ret0, _ := ret[0].(generics.StructType) + return ret0 +} + +// Second indicates an expected call of Second. +func (mr *MockEmbeddingIfaceMockRecorder[T, R]) Second() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Second", reflect.TypeOf((*MockEmbeddingIface[T, R])(nil).Second)) +} + +// Seven mocks base method. +func (m *MockEmbeddingIface[T, R]) Seven(arg0 T) other.One[T] { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Seven", arg0) + ret0, _ := ret[0].(other.One[T]) + return ret0 +} + +// Seven indicates an expected call of Seven. +func (mr *MockEmbeddingIfaceMockRecorder[T, R]) Seven(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Seven", reflect.TypeOf((*MockEmbeddingIface[T, R])(nil).Seven), arg0) +} + +// Six mocks base method. +func (m *MockEmbeddingIface[T, R]) Six(arg0 T) *generics.Baz[R] { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Six", arg0) + ret0, _ := ret[0].(*generics.Baz[R]) + return ret0 +} + +// Six indicates an expected call of Six. +func (mr *MockEmbeddingIfaceMockRecorder[T, R]) Six(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Six", reflect.TypeOf((*MockEmbeddingIface[T, R])(nil).Six), arg0) +} + +// Ten mocks base method. +func (m *MockEmbeddingIface[T, R]) Ten(arg0 *T) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "Ten", arg0) +} + +// Ten indicates an expected call of Ten. +func (mr *MockEmbeddingIfaceMockRecorder[T, R]) Ten(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Ten", reflect.TypeOf((*MockEmbeddingIface[T, R])(nil).Ten), arg0) +} + +// Third mocks base method. +func (m *MockEmbeddingIface[T, R]) Third() other.Five { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Third") + ret0, _ := ret[0].(other.Five) + return ret0 +} + +// Third indicates an expected call of Third. +func (mr *MockEmbeddingIfaceMockRecorder[T, R]) Third() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Third", reflect.TypeOf((*MockEmbeddingIface[T, R])(nil).Third)) +} + +// Thirteen mocks base method. +func (m *MockEmbeddingIface[T, R]) Thirteen(arg0 ...T) *R { + m.ctrl.T.Helper() + varargs := []any{} + for _, a := range arg0 { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Thirteen", varargs...) + ret0, _ := ret[0].(*R) + return ret0 +} + +// Thirteen indicates an expected call of Thirteen. +func (mr *MockEmbeddingIfaceMockRecorder[T, R]) Thirteen(arg0 ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Thirteen", reflect.TypeOf((*MockEmbeddingIface[T, R])(nil).Thirteen), arg0...) +} + +// Three mocks base method. +func (m *MockEmbeddingIface[T, R]) Three(arg0 T) R { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Three", arg0) + ret0, _ := ret[0].(R) + return ret0 +} + +// Three indicates an expected call of Three. +func (mr *MockEmbeddingIfaceMockRecorder[T, R]) Three(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Three", reflect.TypeOf((*MockEmbeddingIface[T, R])(nil).Three), arg0) +} + +// Twelve mocks base method. +func (m *MockEmbeddingIface[T, R]) Twelve(ctx context.Context) <-chan []T { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Twelve", ctx) + ret0, _ := ret[0].(<-chan []T) + return ret0 +} + +// Twelve indicates an expected call of Twelve. +func (mr *MockEmbeddingIfaceMockRecorder[T, R]) Twelve(ctx any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Twelve", reflect.TypeOf((*MockEmbeddingIface[T, R])(nil).Twelve), ctx) +} + +// Two mocks base method. +func (m *MockEmbeddingIface[T, R]) Two(arg0 T) string { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Two", arg0) + ret0, _ := ret[0].(string) + return ret0 +} + +// Two indicates an expected call of Two. +func (mr *MockEmbeddingIfaceMockRecorder[T, R]) Two(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Two", reflect.TypeOf((*MockEmbeddingIface[T, R])(nil).Two), arg0) +} + +// Water mocks base method. +func (m *MockEmbeddingIface[T, R]) Water(arg0 generics.Generator[T]) []generics.Generator[T] { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Water", arg0) + ret0, _ := ret[0].([]generics.Generator[T]) + return ret0 +} + +// Water indicates an expected call of Water. +func (mr *MockEmbeddingIfaceMockRecorder[T, R]) Water(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Water", reflect.TypeOf((*MockEmbeddingIface[T, R])(nil).Water), arg0) +} + +// MockGenerator is a mock of Generator interface. +type MockGenerator[T any] struct { + ctrl *gomock.Controller + recorder *MockGeneratorMockRecorder[T] + isgomock struct{} +} + +// MockGeneratorMockRecorder is the mock recorder for MockGenerator. +type MockGeneratorMockRecorder[T any] struct { + mock *MockGenerator[T] +} + +// NewMockGenerator creates a new mock instance. +func NewMockGenerator[T any](ctrl *gomock.Controller) *MockGenerator[T] { + mock := &MockGenerator[T]{ctrl: ctrl} + mock.recorder = &MockGeneratorMockRecorder[T]{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockGenerator[T]) EXPECT() *MockGeneratorMockRecorder[T] { + return m.recorder +} + +// Generate mocks base method. +func (m *MockGenerator[T]) Generate() T { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Generate") + ret0, _ := ret[0].(T) + return ret0 +} + +// Generate indicates an expected call of Generate. +func (mr *MockGeneratorMockRecorder[T]) Generate() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Generate", reflect.TypeOf((*MockGenerator[T])(nil).Generate)) +} + +// MockGroup is a mock of Group interface. +type MockGroup[T generics.Generator[any]] struct { + ctrl *gomock.Controller + recorder *MockGroupMockRecorder[T] + isgomock struct{} +} + +// MockGroupMockRecorder is the mock recorder for MockGroup. +type MockGroupMockRecorder[T generics.Generator[any]] struct { + mock *MockGroup[T] +} + +// NewMockGroup creates a new mock instance. +func NewMockGroup[T generics.Generator[any]](ctrl *gomock.Controller) *MockGroup[T] { + mock := &MockGroup[T]{ctrl: ctrl} + mock.recorder = &MockGroupMockRecorder[T]{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockGroup[T]) EXPECT() *MockGroupMockRecorder[T] { + return m.recorder +} + +// Join mocks base method. +func (m *MockGroup[T]) Join(ctx context.Context) []T { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Join", ctx) + ret0, _ := ret[0].([]T) + return ret0 +} + +// Join indicates an expected call of Join. +func (mr *MockGroupMockRecorder[T]) Join(ctx any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Join", reflect.TypeOf((*MockGroup[T])(nil).Join), ctx) +} diff --git a/mockgen/internal/tests/generics/package_mode/mock_test.go b/mockgen/internal/tests/generics/package_mode/mock_test.go new file mode 100644 index 0000000..6a4858b --- /dev/null +++ b/mockgen/internal/tests/generics/package_mode/mock_test.go @@ -0,0 +1,503 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: go.uber.org/mock/mockgen/internal/tests/generics (interfaces: Bar,Universe,MilkyWay,SolarSystem,Earth,Water) +// +// Generated by this command: +// +// mockgen --destination=package_mode/mock_test.go --package=package_mode . Bar,Universe,MilkyWay,SolarSystem,Earth,Water +// + +// Package package_mode is a generated GoMock package. +package package_mode + +import ( + reflect "reflect" + + gomock "go.uber.org/mock/gomock" + generics "go.uber.org/mock/mockgen/internal/tests/generics" + other "go.uber.org/mock/mockgen/internal/tests/generics/other" + constraints "golang.org/x/exp/constraints" +) + +// MockBar is a mock of Bar interface. +type MockBar[T any, R any] struct { + ctrl *gomock.Controller + recorder *MockBarMockRecorder[T, R] + isgomock struct{} +} + +// MockBarMockRecorder is the mock recorder for MockBar. +type MockBarMockRecorder[T any, R any] struct { + mock *MockBar[T, R] +} + +// NewMockBar creates a new mock instance. +func NewMockBar[T any, R any](ctrl *gomock.Controller) *MockBar[T, R] { + mock := &MockBar[T, R]{ctrl: ctrl} + mock.recorder = &MockBarMockRecorder[T, R]{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockBar[T, R]) EXPECT() *MockBarMockRecorder[T, R] { + return m.recorder +} + +// Eight mocks base method. +func (m *MockBar[T, R]) Eight(arg0 T) other.Two[T, R] { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Eight", arg0) + ret0, _ := ret[0].(other.Two[T, R]) + return ret0 +} + +// Eight indicates an expected call of Eight. +func (mr *MockBarMockRecorder[T, R]) Eight(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Eight", reflect.TypeOf((*MockBar[T, R])(nil).Eight), arg0) +} + +// Eighteen mocks base method. +func (m *MockBar[T, R]) Eighteen() (generics.Iface[*other.Five], error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Eighteen") + ret0, _ := ret[0].(generics.Iface[*other.Five]) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Eighteen indicates an expected call of Eighteen. +func (mr *MockBarMockRecorder[T, R]) Eighteen() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Eighteen", reflect.TypeOf((*MockBar[T, R])(nil).Eighteen)) +} + +// Eleven mocks base method. +func (m *MockBar[T, R]) Eleven() (*other.One[T], error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Eleven") + ret0, _ := ret[0].(*other.One[T]) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Eleven indicates an expected call of Eleven. +func (mr *MockBarMockRecorder[T, R]) Eleven() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Eleven", reflect.TypeOf((*MockBar[T, R])(nil).Eleven)) +} + +// Fifteen mocks base method. +func (m *MockBar[T, R]) Fifteen() (generics.Iface[generics.StructType], error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Fifteen") + ret0, _ := ret[0].(generics.Iface[generics.StructType]) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Fifteen indicates an expected call of Fifteen. +func (mr *MockBarMockRecorder[T, R]) Fifteen() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Fifteen", reflect.TypeOf((*MockBar[T, R])(nil).Fifteen)) +} + +// Five mocks base method. +func (m *MockBar[T, R]) Five(arg0 T) generics.Baz[T] { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Five", arg0) + ret0, _ := ret[0].(generics.Baz[T]) + return ret0 +} + +// Five indicates an expected call of Five. +func (mr *MockBarMockRecorder[T, R]) Five(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Five", reflect.TypeOf((*MockBar[T, R])(nil).Five), arg0) +} + +// Four mocks base method. +func (m *MockBar[T, R]) Four(arg0 T) generics.Foo[T, R] { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Four", arg0) + ret0, _ := ret[0].(generics.Foo[T, R]) + return ret0 +} + +// Four indicates an expected call of Four. +func (mr *MockBarMockRecorder[T, R]) Four(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Four", reflect.TypeOf((*MockBar[T, R])(nil).Four), arg0) +} + +// Fourteen mocks base method. +func (m *MockBar[T, R]) Fourteen() (*generics.Foo[generics.StructType, generics.StructType2], error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Fourteen") + ret0, _ := ret[0].(*generics.Foo[generics.StructType, generics.StructType2]) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Fourteen indicates an expected call of Fourteen. +func (mr *MockBarMockRecorder[T, R]) Fourteen() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Fourteen", reflect.TypeOf((*MockBar[T, R])(nil).Fourteen)) +} + +// Nine mocks base method. +func (m *MockBar[T, R]) Nine(arg0 generics.Iface[T]) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "Nine", arg0) +} + +// Nine indicates an expected call of Nine. +func (mr *MockBarMockRecorder[T, R]) Nine(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Nine", reflect.TypeOf((*MockBar[T, R])(nil).Nine), arg0) +} + +// Nineteen mocks base method. +func (m *MockBar[T, R]) Nineteen() generics.AliasType { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Nineteen") + ret0, _ := ret[0].(generics.AliasType) + return ret0 +} + +// Nineteen indicates an expected call of Nineteen. +func (mr *MockBarMockRecorder[T, R]) Nineteen() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Nineteen", reflect.TypeOf((*MockBar[T, R])(nil).Nineteen)) +} + +// One mocks base method. +func (m *MockBar[T, R]) One(arg0 string) string { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "One", arg0) + ret0, _ := ret[0].(string) + return ret0 +} + +// One indicates an expected call of One. +func (mr *MockBarMockRecorder[T, R]) One(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "One", reflect.TypeOf((*MockBar[T, R])(nil).One), arg0) +} + +// Seven mocks base method. +func (m *MockBar[T, R]) Seven(arg0 T) other.One[T] { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Seven", arg0) + ret0, _ := ret[0].(other.One[T]) + return ret0 +} + +// Seven indicates an expected call of Seven. +func (mr *MockBarMockRecorder[T, R]) Seven(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Seven", reflect.TypeOf((*MockBar[T, R])(nil).Seven), arg0) +} + +// Seventeen mocks base method. +func (m *MockBar[T, R]) Seventeen() (*generics.Foo[other.Three, other.Four], error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Seventeen") + ret0, _ := ret[0].(*generics.Foo[other.Three, other.Four]) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Seventeen indicates an expected call of Seventeen. +func (mr *MockBarMockRecorder[T, R]) Seventeen() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Seventeen", reflect.TypeOf((*MockBar[T, R])(nil).Seventeen)) +} + +// Six mocks base method. +func (m *MockBar[T, R]) Six(arg0 T) *generics.Baz[T] { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Six", arg0) + ret0, _ := ret[0].(*generics.Baz[T]) + return ret0 +} + +// Six indicates an expected call of Six. +func (mr *MockBarMockRecorder[T, R]) Six(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Six", reflect.TypeOf((*MockBar[T, R])(nil).Six), arg0) +} + +// Sixteen mocks base method. +func (m *MockBar[T, R]) Sixteen() (generics.Baz[other.Three], error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Sixteen") + ret0, _ := ret[0].(generics.Baz[other.Three]) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Sixteen indicates an expected call of Sixteen. +func (mr *MockBarMockRecorder[T, R]) Sixteen() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Sixteen", reflect.TypeOf((*MockBar[T, R])(nil).Sixteen)) +} + +// Ten mocks base method. +func (m *MockBar[T, R]) Ten(arg0 *T) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "Ten", arg0) +} + +// Ten indicates an expected call of Ten. +func (mr *MockBarMockRecorder[T, R]) Ten(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Ten", reflect.TypeOf((*MockBar[T, R])(nil).Ten), arg0) +} + +// Thirteen mocks base method. +func (m *MockBar[T, R]) Thirteen() (generics.Baz[generics.StructType], error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Thirteen") + ret0, _ := ret[0].(generics.Baz[generics.StructType]) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Thirteen indicates an expected call of Thirteen. +func (mr *MockBarMockRecorder[T, R]) Thirteen() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Thirteen", reflect.TypeOf((*MockBar[T, R])(nil).Thirteen)) +} + +// Three mocks base method. +func (m *MockBar[T, R]) Three(arg0 T) R { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Three", arg0) + ret0, _ := ret[0].(R) + return ret0 +} + +// Three indicates an expected call of Three. +func (mr *MockBarMockRecorder[T, R]) Three(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Three", reflect.TypeOf((*MockBar[T, R])(nil).Three), arg0) +} + +// Twelve mocks base method. +func (m *MockBar[T, R]) Twelve() (*other.Two[T, R], error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Twelve") + ret0, _ := ret[0].(*other.Two[T, R]) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Twelve indicates an expected call of Twelve. +func (mr *MockBarMockRecorder[T, R]) Twelve() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Twelve", reflect.TypeOf((*MockBar[T, R])(nil).Twelve)) +} + +// Two mocks base method. +func (m *MockBar[T, R]) Two(arg0 T) string { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Two", arg0) + ret0, _ := ret[0].(string) + return ret0 +} + +// Two indicates an expected call of Two. +func (mr *MockBarMockRecorder[T, R]) Two(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Two", reflect.TypeOf((*MockBar[T, R])(nil).Two), arg0) +} + +// MockUniverse is a mock of Universe interface. +type MockUniverse[T constraints.Signed] struct { + ctrl *gomock.Controller + recorder *MockUniverseMockRecorder[T] + isgomock struct{} +} + +// MockUniverseMockRecorder is the mock recorder for MockUniverse. +type MockUniverseMockRecorder[T constraints.Signed] struct { + mock *MockUniverse[T] +} + +// NewMockUniverse creates a new mock instance. +func NewMockUniverse[T constraints.Signed](ctrl *gomock.Controller) *MockUniverse[T] { + mock := &MockUniverse[T]{ctrl: ctrl} + mock.recorder = &MockUniverseMockRecorder[T]{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockUniverse[T]) EXPECT() *MockUniverseMockRecorder[T] { + return m.recorder +} + +// Water mocks base method. +func (m *MockUniverse[T]) Water(arg0 T) []T { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Water", arg0) + ret0, _ := ret[0].([]T) + return ret0 +} + +// Water indicates an expected call of Water. +func (mr *MockUniverseMockRecorder[T]) Water(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Water", reflect.TypeOf((*MockUniverse[T])(nil).Water), arg0) +} + +// MockMilkyWay is a mock of MilkyWay interface. +type MockMilkyWay[R constraints.Integer] struct { + ctrl *gomock.Controller + recorder *MockMilkyWayMockRecorder[R] + isgomock struct{} +} + +// MockMilkyWayMockRecorder is the mock recorder for MockMilkyWay. +type MockMilkyWayMockRecorder[R constraints.Integer] struct { + mock *MockMilkyWay[R] +} + +// NewMockMilkyWay creates a new mock instance. +func NewMockMilkyWay[R constraints.Integer](ctrl *gomock.Controller) *MockMilkyWay[R] { + mock := &MockMilkyWay[R]{ctrl: ctrl} + mock.recorder = &MockMilkyWayMockRecorder[R]{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockMilkyWay[R]) EXPECT() *MockMilkyWayMockRecorder[R] { + return m.recorder +} + +// Water mocks base method. +func (m *MockMilkyWay[R]) Water(arg0 R) []R { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Water", arg0) + ret0, _ := ret[0].([]R) + return ret0 +} + +// Water indicates an expected call of Water. +func (mr *MockMilkyWayMockRecorder[R]) Water(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Water", reflect.TypeOf((*MockMilkyWay[R])(nil).Water), arg0) +} + +// MockSolarSystem is a mock of SolarSystem interface. +type MockSolarSystem[T constraints.Ordered] struct { + ctrl *gomock.Controller + recorder *MockSolarSystemMockRecorder[T] + isgomock struct{} +} + +// MockSolarSystemMockRecorder is the mock recorder for MockSolarSystem. +type MockSolarSystemMockRecorder[T constraints.Ordered] struct { + mock *MockSolarSystem[T] +} + +// NewMockSolarSystem creates a new mock instance. +func NewMockSolarSystem[T constraints.Ordered](ctrl *gomock.Controller) *MockSolarSystem[T] { + mock := &MockSolarSystem[T]{ctrl: ctrl} + mock.recorder = &MockSolarSystemMockRecorder[T]{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockSolarSystem[T]) EXPECT() *MockSolarSystemMockRecorder[T] { + return m.recorder +} + +// Water mocks base method. +func (m *MockSolarSystem[T]) Water(arg0 T) []T { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Water", arg0) + ret0, _ := ret[0].([]T) + return ret0 +} + +// Water indicates an expected call of Water. +func (mr *MockSolarSystemMockRecorder[T]) Water(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Water", reflect.TypeOf((*MockSolarSystem[T])(nil).Water), arg0) +} + +// MockEarth is a mock of Earth interface. +type MockEarth[R any] struct { + ctrl *gomock.Controller + recorder *MockEarthMockRecorder[R] + isgomock struct{} +} + +// MockEarthMockRecorder is the mock recorder for MockEarth. +type MockEarthMockRecorder[R any] struct { + mock *MockEarth[R] +} + +// NewMockEarth creates a new mock instance. +func NewMockEarth[R any](ctrl *gomock.Controller) *MockEarth[R] { + mock := &MockEarth[R]{ctrl: ctrl} + mock.recorder = &MockEarthMockRecorder[R]{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockEarth[R]) EXPECT() *MockEarthMockRecorder[R] { + return m.recorder +} + +// Water mocks base method. +func (m *MockEarth[R]) Water(arg0 R) []R { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Water", arg0) + ret0, _ := ret[0].([]R) + return ret0 +} + +// Water indicates an expected call of Water. +func (mr *MockEarthMockRecorder[R]) Water(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Water", reflect.TypeOf((*MockEarth[R])(nil).Water), arg0) +} + +// MockWater is a mock of Water interface. +type MockWater[R any, C generics.UnsignedInteger] struct { + ctrl *gomock.Controller + recorder *MockWaterMockRecorder[R, C] + isgomock struct{} +} + +// MockWaterMockRecorder is the mock recorder for MockWater. +type MockWaterMockRecorder[R any, C generics.UnsignedInteger] struct { + mock *MockWater[R, C] +} + +// NewMockWater creates a new mock instance. +func NewMockWater[R any, C generics.UnsignedInteger](ctrl *gomock.Controller) *MockWater[R, C] { + mock := &MockWater[R, C]{ctrl: ctrl} + mock.recorder = &MockWaterMockRecorder[R, C]{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockWater[R, C]) EXPECT() *MockWaterMockRecorder[R, C] { + return m.recorder +} + +// Fish mocks base method. +func (m *MockWater[R, C]) Fish(arg0 R) []C { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Fish", arg0) + ret0, _ := ret[0].([]C) + return ret0 +} + +// Fish indicates an expected call of Fish. +func (mr *MockWaterMockRecorder[R, C]) Fish(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Fish", reflect.TypeOf((*MockWater[R, C])(nil).Fish), arg0) +} diff --git a/mockgen/internal/tests/mock_name/mocks/post_service.go b/mockgen/internal/tests/mock_name/mocks/post_service.go index d8dc033..5b6f975 100644 --- a/mockgen/internal/tests/mock_name/mocks/post_service.go +++ b/mockgen/internal/tests/mock_name/mocks/post_service.go @@ -42,18 +42,18 @@ func (m *PostServiceMock) EXPECT() *PostServiceMockMockRecorder { } // Create mocks base method. -func (m *PostServiceMock) Create(arg0, arg1 string, arg2 *user.User) (*post.Post, error) { +func (m *PostServiceMock) Create(title, body string, author *user.User) (*post.Post, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Create", arg0, arg1, arg2) + ret := m.ctrl.Call(m, "Create", title, body, author) ret0, _ := ret[0].(*post.Post) ret1, _ := ret[1].(error) return ret0, ret1 } // Create indicates an expected call of Create. -func (mr *PostServiceMockMockRecorder) Create(arg0, arg1, arg2 any) *PostServiceMockCreateCall { +func (mr *PostServiceMockMockRecorder) Create(title, body, author any) *PostServiceMockCreateCall { mr.mock.ctrl.T.Helper() - call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Create", reflect.TypeOf((*PostServiceMock)(nil).Create), arg0, arg1, arg2) + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Create", reflect.TypeOf((*PostServiceMock)(nil).Create), title, body, author) return &PostServiceMockCreateCall{Call: call} } diff --git a/mockgen/internal/tests/mock_name/mocks/user_service.go b/mockgen/internal/tests/mock_name/mocks/user_service.go index 6447691..703ac4f 100644 --- a/mockgen/internal/tests/mock_name/mocks/user_service.go +++ b/mockgen/internal/tests/mock_name/mocks/user_service.go @@ -41,18 +41,18 @@ func (m *UserServiceMock) EXPECT() *UserServiceMockMockRecorder { } // Create mocks base method. -func (m *UserServiceMock) Create(arg0 string) (*user.User, error) { +func (m *UserServiceMock) Create(name string) (*user.User, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Create", arg0) + ret := m.ctrl.Call(m, "Create", name) ret0, _ := ret[0].(*user.User) ret1, _ := ret[1].(error) return ret0, ret1 } // Create indicates an expected call of Create. -func (mr *UserServiceMockMockRecorder) Create(arg0 any) *UserServiceMockCreateCall { +func (mr *UserServiceMockMockRecorder) Create(name any) *UserServiceMockCreateCall { mr.mock.ctrl.T.Helper() - call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Create", reflect.TypeOf((*UserServiceMock)(nil).Create), arg0) + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Create", reflect.TypeOf((*UserServiceMock)(nil).Create), name) return &UserServiceMockCreateCall{Call: call} } diff --git a/mockgen/internal/tests/package_mode/cars/cars.go b/mockgen/internal/tests/package_mode/cars/cars.go new file mode 100644 index 0000000..e8b3396 --- /dev/null +++ b/mockgen/internal/tests/package_mode/cars/cars.go @@ -0,0 +1,44 @@ +package cars + +import ( + "go.uber.org/mock/mockgen/internal/tests/package_mode/fuel" +) + +type FuelTank[FuelType fuel.Fuel] struct { + Fuel FuelType + Capacity int +} + +type HyundaiSolaris struct{} + +func (HyundaiSolaris) Refuel(fuel.Gasoline, int) error { + return nil +} + +func (HyundaiSolaris) Brand() string { + return "Hyundai" +} + +func (HyundaiSolaris) FuelTank() FuelTank[fuel.Gasoline] { + return FuelTank[fuel.Gasoline]{ + Fuel: fuel.Gasoline{}, + Capacity: 50, + } +} + +type FordF150 struct{} + +func (FordF150) Brand() string { + return "Ford" +} + +func (FordF150) Refuel(fuel.Diesel, int) error { + return nil +} + +func (FordF150) FuelTank() FuelTank[fuel.Diesel] { + return FuelTank[fuel.Diesel]{ + Fuel: fuel.Diesel{}, + Capacity: 136, + } +} diff --git a/mockgen/internal/tests/package_mode/fuel/fuel.go b/mockgen/internal/tests/package_mode/fuel/fuel.go new file mode 100644 index 0000000..818d3f1 --- /dev/null +++ b/mockgen/internal/tests/package_mode/fuel/fuel.go @@ -0,0 +1,18 @@ +package fuel + +type Fuel interface { + EnergyCapacity() int + Diesel | Gasoline +} + +type Diesel struct{} + +func (Diesel) EnergyCapacity() int { + return 48 +} + +type Gasoline struct{} + +func (Gasoline) EnergyCapacity() int { + return 46 +} diff --git a/mockgen/internal/tests/package_mode/interfaces.go b/mockgen/internal/tests/package_mode/interfaces.go new file mode 100644 index 0000000..aa3df47 --- /dev/null +++ b/mockgen/internal/tests/package_mode/interfaces.go @@ -0,0 +1,68 @@ +package package_mode + +//go:generate mockgen -typed -package=mock -destination=mock/interfaces.go . Food,Eater,Animal,Human,Primate,Car,Driver,UrbanResident,Farmer,Earth + +import ( + "time" + + "go.uber.org/mock/mockgen/internal/tests/package_mode/cars" + "go.uber.org/mock/mockgen/internal/tests/package_mode/fuel" +) + +type Food interface { + Calories() int +} + +type Eater interface { + Eat(foods ...Food) +} + +type Animal interface { + Eater + Breathe() + Sleep(duration time.Duration) +} + +type Primate Animal + +type Human = Primate + +type Car[FuelType fuel.Fuel] interface { + Brand() string + FuelTank() cars.FuelTank[FuelType] + Refuel(fuel FuelType, volume int) error +} + +type Driver[FuelType fuel.Fuel, CarType Car[FuelType]] interface { + Wroom() error + Drive(car CarType) +} + +type UrbanResident interface { + Human + Driver[fuel.Gasoline, cars.HyundaiSolaris] + Do(work *Work) error + LivesInACity() +} + +type Farmer interface { + Human + Driver[fuel.Diesel, cars.FordF150] + Do(work *Work) error + LivesInAVillage() +} + +type Work struct { + Name string +} + +type Counter interface { + int +} + +type HumansCount = int + +type Earth interface { + AddHumans(HumansCount) []Human + HumanPopulation() HumansCount +} diff --git a/mockgen/internal/tests/package_mode/mock/interfaces.go b/mockgen/internal/tests/package_mode/mock/interfaces.go new file mode 100644 index 0000000..1cb6ffd --- /dev/null +++ b/mockgen/internal/tests/package_mode/mock/interfaces.go @@ -0,0 +1,1458 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: go.uber.org/mock/mockgen/internal/tests/package_mode (interfaces: Food,Eater,Animal,Human,Primate,Car,Driver,UrbanResident,Farmer,Earth) +// +// Generated by this command: +// +// mockgen -typed -package=mock -destination=mock/interfaces.go . Food,Eater,Animal,Human,Primate,Car,Driver,UrbanResident,Farmer,Earth +// + +// Package mock is a generated GoMock package. +package mock + +import ( + reflect "reflect" + time "time" + + gomock "go.uber.org/mock/gomock" + package_mode "go.uber.org/mock/mockgen/internal/tests/package_mode" + cars "go.uber.org/mock/mockgen/internal/tests/package_mode/cars" + fuel "go.uber.org/mock/mockgen/internal/tests/package_mode/fuel" +) + +// MockFood is a mock of Food interface. +type MockFood struct { + ctrl *gomock.Controller + recorder *MockFoodMockRecorder + isgomock struct{} +} + +// MockFoodMockRecorder is the mock recorder for MockFood. +type MockFoodMockRecorder struct { + mock *MockFood +} + +// NewMockFood creates a new mock instance. +func NewMockFood(ctrl *gomock.Controller) *MockFood { + mock := &MockFood{ctrl: ctrl} + mock.recorder = &MockFoodMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockFood) EXPECT() *MockFoodMockRecorder { + return m.recorder +} + +// Calories mocks base method. +func (m *MockFood) Calories() int { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Calories") + ret0, _ := ret[0].(int) + return ret0 +} + +// Calories indicates an expected call of Calories. +func (mr *MockFoodMockRecorder) Calories() *MockFoodCaloriesCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Calories", reflect.TypeOf((*MockFood)(nil).Calories)) + return &MockFoodCaloriesCall{Call: call} +} + +// MockFoodCaloriesCall wrap *gomock.Call +type MockFoodCaloriesCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockFoodCaloriesCall) Return(arg0 int) *MockFoodCaloriesCall { + c.Call = c.Call.Return(arg0) + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockFoodCaloriesCall) Do(f func() int) *MockFoodCaloriesCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockFoodCaloriesCall) DoAndReturn(f func() int) *MockFoodCaloriesCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// MockEater is a mock of Eater interface. +type MockEater struct { + ctrl *gomock.Controller + recorder *MockEaterMockRecorder + isgomock struct{} +} + +// MockEaterMockRecorder is the mock recorder for MockEater. +type MockEaterMockRecorder struct { + mock *MockEater +} + +// NewMockEater creates a new mock instance. +func NewMockEater(ctrl *gomock.Controller) *MockEater { + mock := &MockEater{ctrl: ctrl} + mock.recorder = &MockEaterMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockEater) EXPECT() *MockEaterMockRecorder { + return m.recorder +} + +// Eat mocks base method. +func (m *MockEater) Eat(foods ...package_mode.Food) { + m.ctrl.T.Helper() + varargs := []any{} + for _, a := range foods { + varargs = append(varargs, a) + } + m.ctrl.Call(m, "Eat", varargs...) +} + +// Eat indicates an expected call of Eat. +func (mr *MockEaterMockRecorder) Eat(foods ...any) *MockEaterEatCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Eat", reflect.TypeOf((*MockEater)(nil).Eat), foods...) + return &MockEaterEatCall{Call: call} +} + +// MockEaterEatCall wrap *gomock.Call +type MockEaterEatCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockEaterEatCall) Return() *MockEaterEatCall { + c.Call = c.Call.Return() + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockEaterEatCall) Do(f func(...package_mode.Food)) *MockEaterEatCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockEaterEatCall) DoAndReturn(f func(...package_mode.Food)) *MockEaterEatCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// MockAnimal is a mock of Animal interface. +type MockAnimal struct { + ctrl *gomock.Controller + recorder *MockAnimalMockRecorder + isgomock struct{} +} + +// MockAnimalMockRecorder is the mock recorder for MockAnimal. +type MockAnimalMockRecorder struct { + mock *MockAnimal +} + +// NewMockAnimal creates a new mock instance. +func NewMockAnimal(ctrl *gomock.Controller) *MockAnimal { + mock := &MockAnimal{ctrl: ctrl} + mock.recorder = &MockAnimalMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockAnimal) EXPECT() *MockAnimalMockRecorder { + return m.recorder +} + +// Breathe mocks base method. +func (m *MockAnimal) Breathe() { + m.ctrl.T.Helper() + m.ctrl.Call(m, "Breathe") +} + +// Breathe indicates an expected call of Breathe. +func (mr *MockAnimalMockRecorder) Breathe() *MockAnimalBreatheCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Breathe", reflect.TypeOf((*MockAnimal)(nil).Breathe)) + return &MockAnimalBreatheCall{Call: call} +} + +// MockAnimalBreatheCall wrap *gomock.Call +type MockAnimalBreatheCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockAnimalBreatheCall) Return() *MockAnimalBreatheCall { + c.Call = c.Call.Return() + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockAnimalBreatheCall) Do(f func()) *MockAnimalBreatheCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockAnimalBreatheCall) DoAndReturn(f func()) *MockAnimalBreatheCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// Eat mocks base method. +func (m *MockAnimal) Eat(foods ...package_mode.Food) { + m.ctrl.T.Helper() + varargs := []any{} + for _, a := range foods { + varargs = append(varargs, a) + } + m.ctrl.Call(m, "Eat", varargs...) +} + +// Eat indicates an expected call of Eat. +func (mr *MockAnimalMockRecorder) Eat(foods ...any) *MockAnimalEatCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Eat", reflect.TypeOf((*MockAnimal)(nil).Eat), foods...) + return &MockAnimalEatCall{Call: call} +} + +// MockAnimalEatCall wrap *gomock.Call +type MockAnimalEatCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockAnimalEatCall) Return() *MockAnimalEatCall { + c.Call = c.Call.Return() + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockAnimalEatCall) Do(f func(...package_mode.Food)) *MockAnimalEatCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockAnimalEatCall) DoAndReturn(f func(...package_mode.Food)) *MockAnimalEatCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// Sleep mocks base method. +func (m *MockAnimal) Sleep(duration time.Duration) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "Sleep", duration) +} + +// Sleep indicates an expected call of Sleep. +func (mr *MockAnimalMockRecorder) Sleep(duration any) *MockAnimalSleepCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Sleep", reflect.TypeOf((*MockAnimal)(nil).Sleep), duration) + return &MockAnimalSleepCall{Call: call} +} + +// MockAnimalSleepCall wrap *gomock.Call +type MockAnimalSleepCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockAnimalSleepCall) Return() *MockAnimalSleepCall { + c.Call = c.Call.Return() + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockAnimalSleepCall) Do(f func(time.Duration)) *MockAnimalSleepCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockAnimalSleepCall) DoAndReturn(f func(time.Duration)) *MockAnimalSleepCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// MockHuman is a mock of Human interface. +type MockHuman struct { + ctrl *gomock.Controller + recorder *MockHumanMockRecorder + isgomock struct{} +} + +// MockHumanMockRecorder is the mock recorder for MockHuman. +type MockHumanMockRecorder struct { + mock *MockHuman +} + +// NewMockHuman creates a new mock instance. +func NewMockHuman(ctrl *gomock.Controller) *MockHuman { + mock := &MockHuman{ctrl: ctrl} + mock.recorder = &MockHumanMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockHuman) EXPECT() *MockHumanMockRecorder { + return m.recorder +} + +// Breathe mocks base method. +func (m *MockHuman) Breathe() { + m.ctrl.T.Helper() + m.ctrl.Call(m, "Breathe") +} + +// Breathe indicates an expected call of Breathe. +func (mr *MockHumanMockRecorder) Breathe() *MockHumanBreatheCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Breathe", reflect.TypeOf((*MockHuman)(nil).Breathe)) + return &MockHumanBreatheCall{Call: call} +} + +// MockHumanBreatheCall wrap *gomock.Call +type MockHumanBreatheCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockHumanBreatheCall) Return() *MockHumanBreatheCall { + c.Call = c.Call.Return() + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockHumanBreatheCall) Do(f func()) *MockHumanBreatheCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockHumanBreatheCall) DoAndReturn(f func()) *MockHumanBreatheCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// Eat mocks base method. +func (m *MockHuman) Eat(foods ...package_mode.Food) { + m.ctrl.T.Helper() + varargs := []any{} + for _, a := range foods { + varargs = append(varargs, a) + } + m.ctrl.Call(m, "Eat", varargs...) +} + +// Eat indicates an expected call of Eat. +func (mr *MockHumanMockRecorder) Eat(foods ...any) *MockHumanEatCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Eat", reflect.TypeOf((*MockHuman)(nil).Eat), foods...) + return &MockHumanEatCall{Call: call} +} + +// MockHumanEatCall wrap *gomock.Call +type MockHumanEatCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockHumanEatCall) Return() *MockHumanEatCall { + c.Call = c.Call.Return() + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockHumanEatCall) Do(f func(...package_mode.Food)) *MockHumanEatCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockHumanEatCall) DoAndReturn(f func(...package_mode.Food)) *MockHumanEatCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// Sleep mocks base method. +func (m *MockHuman) Sleep(duration time.Duration) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "Sleep", duration) +} + +// Sleep indicates an expected call of Sleep. +func (mr *MockHumanMockRecorder) Sleep(duration any) *MockHumanSleepCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Sleep", reflect.TypeOf((*MockHuman)(nil).Sleep), duration) + return &MockHumanSleepCall{Call: call} +} + +// MockHumanSleepCall wrap *gomock.Call +type MockHumanSleepCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockHumanSleepCall) Return() *MockHumanSleepCall { + c.Call = c.Call.Return() + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockHumanSleepCall) Do(f func(time.Duration)) *MockHumanSleepCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockHumanSleepCall) DoAndReturn(f func(time.Duration)) *MockHumanSleepCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// MockPrimate is a mock of Primate interface. +type MockPrimate struct { + ctrl *gomock.Controller + recorder *MockPrimateMockRecorder + isgomock struct{} +} + +// MockPrimateMockRecorder is the mock recorder for MockPrimate. +type MockPrimateMockRecorder struct { + mock *MockPrimate +} + +// NewMockPrimate creates a new mock instance. +func NewMockPrimate(ctrl *gomock.Controller) *MockPrimate { + mock := &MockPrimate{ctrl: ctrl} + mock.recorder = &MockPrimateMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockPrimate) EXPECT() *MockPrimateMockRecorder { + return m.recorder +} + +// Breathe mocks base method. +func (m *MockPrimate) Breathe() { + m.ctrl.T.Helper() + m.ctrl.Call(m, "Breathe") +} + +// Breathe indicates an expected call of Breathe. +func (mr *MockPrimateMockRecorder) Breathe() *MockPrimateBreatheCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Breathe", reflect.TypeOf((*MockPrimate)(nil).Breathe)) + return &MockPrimateBreatheCall{Call: call} +} + +// MockPrimateBreatheCall wrap *gomock.Call +type MockPrimateBreatheCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockPrimateBreatheCall) Return() *MockPrimateBreatheCall { + c.Call = c.Call.Return() + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockPrimateBreatheCall) Do(f func()) *MockPrimateBreatheCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockPrimateBreatheCall) DoAndReturn(f func()) *MockPrimateBreatheCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// Eat mocks base method. +func (m *MockPrimate) Eat(foods ...package_mode.Food) { + m.ctrl.T.Helper() + varargs := []any{} + for _, a := range foods { + varargs = append(varargs, a) + } + m.ctrl.Call(m, "Eat", varargs...) +} + +// Eat indicates an expected call of Eat. +func (mr *MockPrimateMockRecorder) Eat(foods ...any) *MockPrimateEatCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Eat", reflect.TypeOf((*MockPrimate)(nil).Eat), foods...) + return &MockPrimateEatCall{Call: call} +} + +// MockPrimateEatCall wrap *gomock.Call +type MockPrimateEatCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockPrimateEatCall) Return() *MockPrimateEatCall { + c.Call = c.Call.Return() + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockPrimateEatCall) Do(f func(...package_mode.Food)) *MockPrimateEatCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockPrimateEatCall) DoAndReturn(f func(...package_mode.Food)) *MockPrimateEatCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// Sleep mocks base method. +func (m *MockPrimate) Sleep(duration time.Duration) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "Sleep", duration) +} + +// Sleep indicates an expected call of Sleep. +func (mr *MockPrimateMockRecorder) Sleep(duration any) *MockPrimateSleepCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Sleep", reflect.TypeOf((*MockPrimate)(nil).Sleep), duration) + return &MockPrimateSleepCall{Call: call} +} + +// MockPrimateSleepCall wrap *gomock.Call +type MockPrimateSleepCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockPrimateSleepCall) Return() *MockPrimateSleepCall { + c.Call = c.Call.Return() + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockPrimateSleepCall) Do(f func(time.Duration)) *MockPrimateSleepCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockPrimateSleepCall) DoAndReturn(f func(time.Duration)) *MockPrimateSleepCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// MockCar is a mock of Car interface. +type MockCar[FuelType fuel.Fuel] struct { + ctrl *gomock.Controller + recorder *MockCarMockRecorder[FuelType] + isgomock struct{} +} + +// MockCarMockRecorder is the mock recorder for MockCar. +type MockCarMockRecorder[FuelType fuel.Fuel] struct { + mock *MockCar[FuelType] +} + +// NewMockCar creates a new mock instance. +func NewMockCar[FuelType fuel.Fuel](ctrl *gomock.Controller) *MockCar[FuelType] { + mock := &MockCar[FuelType]{ctrl: ctrl} + mock.recorder = &MockCarMockRecorder[FuelType]{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockCar[FuelType]) EXPECT() *MockCarMockRecorder[FuelType] { + return m.recorder +} + +// Brand mocks base method. +func (m *MockCar[FuelType]) Brand() string { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Brand") + ret0, _ := ret[0].(string) + return ret0 +} + +// Brand indicates an expected call of Brand. +func (mr *MockCarMockRecorder[FuelType]) Brand() *MockCarBrandCall[FuelType] { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Brand", reflect.TypeOf((*MockCar[FuelType])(nil).Brand)) + return &MockCarBrandCall[FuelType]{Call: call} +} + +// MockCarBrandCall wrap *gomock.Call +type MockCarBrandCall[FuelType fuel.Fuel] struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockCarBrandCall[FuelType]) Return(arg0 string) *MockCarBrandCall[FuelType] { + c.Call = c.Call.Return(arg0) + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockCarBrandCall[FuelType]) Do(f func() string) *MockCarBrandCall[FuelType] { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockCarBrandCall[FuelType]) DoAndReturn(f func() string) *MockCarBrandCall[FuelType] { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// FuelTank mocks base method. +func (m *MockCar[FuelType]) FuelTank() cars.FuelTank[FuelType] { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "FuelTank") + ret0, _ := ret[0].(cars.FuelTank[FuelType]) + return ret0 +} + +// FuelTank indicates an expected call of FuelTank. +func (mr *MockCarMockRecorder[FuelType]) FuelTank() *MockCarFuelTankCall[FuelType] { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FuelTank", reflect.TypeOf((*MockCar[FuelType])(nil).FuelTank)) + return &MockCarFuelTankCall[FuelType]{Call: call} +} + +// MockCarFuelTankCall wrap *gomock.Call +type MockCarFuelTankCall[FuelType fuel.Fuel] struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockCarFuelTankCall[FuelType]) Return(arg0 cars.FuelTank[FuelType]) *MockCarFuelTankCall[FuelType] { + c.Call = c.Call.Return(arg0) + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockCarFuelTankCall[FuelType]) Do(f func() cars.FuelTank[FuelType]) *MockCarFuelTankCall[FuelType] { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockCarFuelTankCall[FuelType]) DoAndReturn(f func() cars.FuelTank[FuelType]) *MockCarFuelTankCall[FuelType] { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// Refuel mocks base method. +func (m *MockCar[FuelType]) Refuel(fuel FuelType, volume int) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Refuel", fuel, volume) + ret0, _ := ret[0].(error) + return ret0 +} + +// Refuel indicates an expected call of Refuel. +func (mr *MockCarMockRecorder[FuelType]) Refuel(fuel, volume any) *MockCarRefuelCall[FuelType] { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Refuel", reflect.TypeOf((*MockCar[FuelType])(nil).Refuel), fuel, volume) + return &MockCarRefuelCall[FuelType]{Call: call} +} + +// MockCarRefuelCall wrap *gomock.Call +type MockCarRefuelCall[FuelType fuel.Fuel] struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockCarRefuelCall[FuelType]) Return(arg0 error) *MockCarRefuelCall[FuelType] { + c.Call = c.Call.Return(arg0) + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockCarRefuelCall[FuelType]) Do(f func(FuelType, int) error) *MockCarRefuelCall[FuelType] { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockCarRefuelCall[FuelType]) DoAndReturn(f func(FuelType, int) error) *MockCarRefuelCall[FuelType] { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// MockDriver is a mock of Driver interface. +type MockDriver[FuelType fuel.Fuel, CarType package_mode.Car[FuelType]] struct { + ctrl *gomock.Controller + recorder *MockDriverMockRecorder[FuelType, CarType] + isgomock struct{} +} + +// MockDriverMockRecorder is the mock recorder for MockDriver. +type MockDriverMockRecorder[FuelType fuel.Fuel, CarType package_mode.Car[FuelType]] struct { + mock *MockDriver[FuelType, CarType] +} + +// NewMockDriver creates a new mock instance. +func NewMockDriver[FuelType fuel.Fuel, CarType package_mode.Car[FuelType]](ctrl *gomock.Controller) *MockDriver[FuelType, CarType] { + mock := &MockDriver[FuelType, CarType]{ctrl: ctrl} + mock.recorder = &MockDriverMockRecorder[FuelType, CarType]{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockDriver[FuelType, CarType]) EXPECT() *MockDriverMockRecorder[FuelType, CarType] { + return m.recorder +} + +// Drive mocks base method. +func (m *MockDriver[FuelType, CarType]) Drive(car CarType) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "Drive", car) +} + +// Drive indicates an expected call of Drive. +func (mr *MockDriverMockRecorder[FuelType, CarType]) Drive(car any) *MockDriverDriveCall[FuelType, CarType] { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Drive", reflect.TypeOf((*MockDriver[FuelType, CarType])(nil).Drive), car) + return &MockDriverDriveCall[FuelType, CarType]{Call: call} +} + +// MockDriverDriveCall wrap *gomock.Call +type MockDriverDriveCall[FuelType fuel.Fuel, CarType package_mode.Car[FuelType]] struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockDriverDriveCall[FuelType, CarType]) Return() *MockDriverDriveCall[FuelType, CarType] { + c.Call = c.Call.Return() + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockDriverDriveCall[FuelType, CarType]) Do(f func(CarType)) *MockDriverDriveCall[FuelType, CarType] { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockDriverDriveCall[FuelType, CarType]) DoAndReturn(f func(CarType)) *MockDriverDriveCall[FuelType, CarType] { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// Wroom mocks base method. +func (m *MockDriver[FuelType, CarType]) Wroom() error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Wroom") + ret0, _ := ret[0].(error) + return ret0 +} + +// Wroom indicates an expected call of Wroom. +func (mr *MockDriverMockRecorder[FuelType, CarType]) Wroom() *MockDriverWroomCall[FuelType, CarType] { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Wroom", reflect.TypeOf((*MockDriver[FuelType, CarType])(nil).Wroom)) + return &MockDriverWroomCall[FuelType, CarType]{Call: call} +} + +// MockDriverWroomCall wrap *gomock.Call +type MockDriverWroomCall[FuelType fuel.Fuel, CarType package_mode.Car[FuelType]] struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockDriverWroomCall[FuelType, CarType]) Return(arg0 error) *MockDriverWroomCall[FuelType, CarType] { + c.Call = c.Call.Return(arg0) + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockDriverWroomCall[FuelType, CarType]) Do(f func() error) *MockDriverWroomCall[FuelType, CarType] { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockDriverWroomCall[FuelType, CarType]) DoAndReturn(f func() error) *MockDriverWroomCall[FuelType, CarType] { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// MockUrbanResident is a mock of UrbanResident interface. +type MockUrbanResident struct { + ctrl *gomock.Controller + recorder *MockUrbanResidentMockRecorder + isgomock struct{} +} + +// MockUrbanResidentMockRecorder is the mock recorder for MockUrbanResident. +type MockUrbanResidentMockRecorder struct { + mock *MockUrbanResident +} + +// NewMockUrbanResident creates a new mock instance. +func NewMockUrbanResident(ctrl *gomock.Controller) *MockUrbanResident { + mock := &MockUrbanResident{ctrl: ctrl} + mock.recorder = &MockUrbanResidentMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockUrbanResident) EXPECT() *MockUrbanResidentMockRecorder { + return m.recorder +} + +// Breathe mocks base method. +func (m *MockUrbanResident) Breathe() { + m.ctrl.T.Helper() + m.ctrl.Call(m, "Breathe") +} + +// Breathe indicates an expected call of Breathe. +func (mr *MockUrbanResidentMockRecorder) Breathe() *MockUrbanResidentBreatheCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Breathe", reflect.TypeOf((*MockUrbanResident)(nil).Breathe)) + return &MockUrbanResidentBreatheCall{Call: call} +} + +// MockUrbanResidentBreatheCall wrap *gomock.Call +type MockUrbanResidentBreatheCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockUrbanResidentBreatheCall) Return() *MockUrbanResidentBreatheCall { + c.Call = c.Call.Return() + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockUrbanResidentBreatheCall) Do(f func()) *MockUrbanResidentBreatheCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockUrbanResidentBreatheCall) DoAndReturn(f func()) *MockUrbanResidentBreatheCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// Do mocks base method. +func (m *MockUrbanResident) Do(work *package_mode.Work) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Do", work) + ret0, _ := ret[0].(error) + return ret0 +} + +// Do indicates an expected call of Do. +func (mr *MockUrbanResidentMockRecorder) Do(work any) *MockUrbanResidentDoCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Do", reflect.TypeOf((*MockUrbanResident)(nil).Do), work) + return &MockUrbanResidentDoCall{Call: call} +} + +// MockUrbanResidentDoCall wrap *gomock.Call +type MockUrbanResidentDoCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockUrbanResidentDoCall) Return(arg0 error) *MockUrbanResidentDoCall { + c.Call = c.Call.Return(arg0) + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockUrbanResidentDoCall) Do(f func(*package_mode.Work) error) *MockUrbanResidentDoCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockUrbanResidentDoCall) DoAndReturn(f func(*package_mode.Work) error) *MockUrbanResidentDoCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// Drive mocks base method. +func (m *MockUrbanResident) Drive(car cars.HyundaiSolaris) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "Drive", car) +} + +// Drive indicates an expected call of Drive. +func (mr *MockUrbanResidentMockRecorder) Drive(car any) *MockUrbanResidentDriveCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Drive", reflect.TypeOf((*MockUrbanResident)(nil).Drive), car) + return &MockUrbanResidentDriveCall{Call: call} +} + +// MockUrbanResidentDriveCall wrap *gomock.Call +type MockUrbanResidentDriveCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockUrbanResidentDriveCall) Return() *MockUrbanResidentDriveCall { + c.Call = c.Call.Return() + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockUrbanResidentDriveCall) Do(f func(cars.HyundaiSolaris)) *MockUrbanResidentDriveCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockUrbanResidentDriveCall) DoAndReturn(f func(cars.HyundaiSolaris)) *MockUrbanResidentDriveCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// Eat mocks base method. +func (m *MockUrbanResident) Eat(foods ...package_mode.Food) { + m.ctrl.T.Helper() + varargs := []any{} + for _, a := range foods { + varargs = append(varargs, a) + } + m.ctrl.Call(m, "Eat", varargs...) +} + +// Eat indicates an expected call of Eat. +func (mr *MockUrbanResidentMockRecorder) Eat(foods ...any) *MockUrbanResidentEatCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Eat", reflect.TypeOf((*MockUrbanResident)(nil).Eat), foods...) + return &MockUrbanResidentEatCall{Call: call} +} + +// MockUrbanResidentEatCall wrap *gomock.Call +type MockUrbanResidentEatCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockUrbanResidentEatCall) Return() *MockUrbanResidentEatCall { + c.Call = c.Call.Return() + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockUrbanResidentEatCall) Do(f func(...package_mode.Food)) *MockUrbanResidentEatCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockUrbanResidentEatCall) DoAndReturn(f func(...package_mode.Food)) *MockUrbanResidentEatCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// LivesInACity mocks base method. +func (m *MockUrbanResident) LivesInACity() { + m.ctrl.T.Helper() + m.ctrl.Call(m, "LivesInACity") +} + +// LivesInACity indicates an expected call of LivesInACity. +func (mr *MockUrbanResidentMockRecorder) LivesInACity() *MockUrbanResidentLivesInACityCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LivesInACity", reflect.TypeOf((*MockUrbanResident)(nil).LivesInACity)) + return &MockUrbanResidentLivesInACityCall{Call: call} +} + +// MockUrbanResidentLivesInACityCall wrap *gomock.Call +type MockUrbanResidentLivesInACityCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockUrbanResidentLivesInACityCall) Return() *MockUrbanResidentLivesInACityCall { + c.Call = c.Call.Return() + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockUrbanResidentLivesInACityCall) Do(f func()) *MockUrbanResidentLivesInACityCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockUrbanResidentLivesInACityCall) DoAndReturn(f func()) *MockUrbanResidentLivesInACityCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// Sleep mocks base method. +func (m *MockUrbanResident) Sleep(duration time.Duration) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "Sleep", duration) +} + +// Sleep indicates an expected call of Sleep. +func (mr *MockUrbanResidentMockRecorder) Sleep(duration any) *MockUrbanResidentSleepCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Sleep", reflect.TypeOf((*MockUrbanResident)(nil).Sleep), duration) + return &MockUrbanResidentSleepCall{Call: call} +} + +// MockUrbanResidentSleepCall wrap *gomock.Call +type MockUrbanResidentSleepCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockUrbanResidentSleepCall) Return() *MockUrbanResidentSleepCall { + c.Call = c.Call.Return() + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockUrbanResidentSleepCall) Do(f func(time.Duration)) *MockUrbanResidentSleepCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockUrbanResidentSleepCall) DoAndReturn(f func(time.Duration)) *MockUrbanResidentSleepCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// Wroom mocks base method. +func (m *MockUrbanResident) Wroom() error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Wroom") + ret0, _ := ret[0].(error) + return ret0 +} + +// Wroom indicates an expected call of Wroom. +func (mr *MockUrbanResidentMockRecorder) Wroom() *MockUrbanResidentWroomCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Wroom", reflect.TypeOf((*MockUrbanResident)(nil).Wroom)) + return &MockUrbanResidentWroomCall{Call: call} +} + +// MockUrbanResidentWroomCall wrap *gomock.Call +type MockUrbanResidentWroomCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockUrbanResidentWroomCall) Return(arg0 error) *MockUrbanResidentWroomCall { + c.Call = c.Call.Return(arg0) + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockUrbanResidentWroomCall) Do(f func() error) *MockUrbanResidentWroomCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockUrbanResidentWroomCall) DoAndReturn(f func() error) *MockUrbanResidentWroomCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// MockFarmer is a mock of Farmer interface. +type MockFarmer struct { + ctrl *gomock.Controller + recorder *MockFarmerMockRecorder + isgomock struct{} +} + +// MockFarmerMockRecorder is the mock recorder for MockFarmer. +type MockFarmerMockRecorder struct { + mock *MockFarmer +} + +// NewMockFarmer creates a new mock instance. +func NewMockFarmer(ctrl *gomock.Controller) *MockFarmer { + mock := &MockFarmer{ctrl: ctrl} + mock.recorder = &MockFarmerMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockFarmer) EXPECT() *MockFarmerMockRecorder { + return m.recorder +} + +// Breathe mocks base method. +func (m *MockFarmer) Breathe() { + m.ctrl.T.Helper() + m.ctrl.Call(m, "Breathe") +} + +// Breathe indicates an expected call of Breathe. +func (mr *MockFarmerMockRecorder) Breathe() *MockFarmerBreatheCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Breathe", reflect.TypeOf((*MockFarmer)(nil).Breathe)) + return &MockFarmerBreatheCall{Call: call} +} + +// MockFarmerBreatheCall wrap *gomock.Call +type MockFarmerBreatheCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockFarmerBreatheCall) Return() *MockFarmerBreatheCall { + c.Call = c.Call.Return() + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockFarmerBreatheCall) Do(f func()) *MockFarmerBreatheCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockFarmerBreatheCall) DoAndReturn(f func()) *MockFarmerBreatheCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// Do mocks base method. +func (m *MockFarmer) Do(work *package_mode.Work) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Do", work) + ret0, _ := ret[0].(error) + return ret0 +} + +// Do indicates an expected call of Do. +func (mr *MockFarmerMockRecorder) Do(work any) *MockFarmerDoCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Do", reflect.TypeOf((*MockFarmer)(nil).Do), work) + return &MockFarmerDoCall{Call: call} +} + +// MockFarmerDoCall wrap *gomock.Call +type MockFarmerDoCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockFarmerDoCall) Return(arg0 error) *MockFarmerDoCall { + c.Call = c.Call.Return(arg0) + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockFarmerDoCall) Do(f func(*package_mode.Work) error) *MockFarmerDoCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockFarmerDoCall) DoAndReturn(f func(*package_mode.Work) error) *MockFarmerDoCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// Drive mocks base method. +func (m *MockFarmer) Drive(car cars.FordF150) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "Drive", car) +} + +// Drive indicates an expected call of Drive. +func (mr *MockFarmerMockRecorder) Drive(car any) *MockFarmerDriveCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Drive", reflect.TypeOf((*MockFarmer)(nil).Drive), car) + return &MockFarmerDriveCall{Call: call} +} + +// MockFarmerDriveCall wrap *gomock.Call +type MockFarmerDriveCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockFarmerDriveCall) Return() *MockFarmerDriveCall { + c.Call = c.Call.Return() + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockFarmerDriveCall) Do(f func(cars.FordF150)) *MockFarmerDriveCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockFarmerDriveCall) DoAndReturn(f func(cars.FordF150)) *MockFarmerDriveCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// Eat mocks base method. +func (m *MockFarmer) Eat(foods ...package_mode.Food) { + m.ctrl.T.Helper() + varargs := []any{} + for _, a := range foods { + varargs = append(varargs, a) + } + m.ctrl.Call(m, "Eat", varargs...) +} + +// Eat indicates an expected call of Eat. +func (mr *MockFarmerMockRecorder) Eat(foods ...any) *MockFarmerEatCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Eat", reflect.TypeOf((*MockFarmer)(nil).Eat), foods...) + return &MockFarmerEatCall{Call: call} +} + +// MockFarmerEatCall wrap *gomock.Call +type MockFarmerEatCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockFarmerEatCall) Return() *MockFarmerEatCall { + c.Call = c.Call.Return() + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockFarmerEatCall) Do(f func(...package_mode.Food)) *MockFarmerEatCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockFarmerEatCall) DoAndReturn(f func(...package_mode.Food)) *MockFarmerEatCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// LivesInAVillage mocks base method. +func (m *MockFarmer) LivesInAVillage() { + m.ctrl.T.Helper() + m.ctrl.Call(m, "LivesInAVillage") +} + +// LivesInAVillage indicates an expected call of LivesInAVillage. +func (mr *MockFarmerMockRecorder) LivesInAVillage() *MockFarmerLivesInAVillageCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LivesInAVillage", reflect.TypeOf((*MockFarmer)(nil).LivesInAVillage)) + return &MockFarmerLivesInAVillageCall{Call: call} +} + +// MockFarmerLivesInAVillageCall wrap *gomock.Call +type MockFarmerLivesInAVillageCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockFarmerLivesInAVillageCall) Return() *MockFarmerLivesInAVillageCall { + c.Call = c.Call.Return() + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockFarmerLivesInAVillageCall) Do(f func()) *MockFarmerLivesInAVillageCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockFarmerLivesInAVillageCall) DoAndReturn(f func()) *MockFarmerLivesInAVillageCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// Sleep mocks base method. +func (m *MockFarmer) Sleep(duration time.Duration) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "Sleep", duration) +} + +// Sleep indicates an expected call of Sleep. +func (mr *MockFarmerMockRecorder) Sleep(duration any) *MockFarmerSleepCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Sleep", reflect.TypeOf((*MockFarmer)(nil).Sleep), duration) + return &MockFarmerSleepCall{Call: call} +} + +// MockFarmerSleepCall wrap *gomock.Call +type MockFarmerSleepCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockFarmerSleepCall) Return() *MockFarmerSleepCall { + c.Call = c.Call.Return() + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockFarmerSleepCall) Do(f func(time.Duration)) *MockFarmerSleepCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockFarmerSleepCall) DoAndReturn(f func(time.Duration)) *MockFarmerSleepCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// Wroom mocks base method. +func (m *MockFarmer) Wroom() error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Wroom") + ret0, _ := ret[0].(error) + return ret0 +} + +// Wroom indicates an expected call of Wroom. +func (mr *MockFarmerMockRecorder) Wroom() *MockFarmerWroomCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Wroom", reflect.TypeOf((*MockFarmer)(nil).Wroom)) + return &MockFarmerWroomCall{Call: call} +} + +// MockFarmerWroomCall wrap *gomock.Call +type MockFarmerWroomCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockFarmerWroomCall) Return(arg0 error) *MockFarmerWroomCall { + c.Call = c.Call.Return(arg0) + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockFarmerWroomCall) Do(f func() error) *MockFarmerWroomCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockFarmerWroomCall) DoAndReturn(f func() error) *MockFarmerWroomCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// MockEarth is a mock of Earth interface. +type MockEarth struct { + ctrl *gomock.Controller + recorder *MockEarthMockRecorder + isgomock struct{} +} + +// MockEarthMockRecorder is the mock recorder for MockEarth. +type MockEarthMockRecorder struct { + mock *MockEarth +} + +// NewMockEarth creates a new mock instance. +func NewMockEarth(ctrl *gomock.Controller) *MockEarth { + mock := &MockEarth{ctrl: ctrl} + mock.recorder = &MockEarthMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockEarth) EXPECT() *MockEarthMockRecorder { + return m.recorder +} + +// AddHumans mocks base method. +func (m *MockEarth) AddHumans(arg0 int) []package_mode.Primate { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "AddHumans", arg0) + ret0, _ := ret[0].([]package_mode.Primate) + return ret0 +} + +// AddHumans indicates an expected call of AddHumans. +func (mr *MockEarthMockRecorder) AddHumans(arg0 any) *MockEarthAddHumansCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddHumans", reflect.TypeOf((*MockEarth)(nil).AddHumans), arg0) + return &MockEarthAddHumansCall{Call: call} +} + +// MockEarthAddHumansCall wrap *gomock.Call +type MockEarthAddHumansCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockEarthAddHumansCall) Return(arg0 []package_mode.Primate) *MockEarthAddHumansCall { + c.Call = c.Call.Return(arg0) + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockEarthAddHumansCall) Do(f func(int) []package_mode.Primate) *MockEarthAddHumansCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockEarthAddHumansCall) DoAndReturn(f func(int) []package_mode.Primate) *MockEarthAddHumansCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + +// HumanPopulation mocks base method. +func (m *MockEarth) HumanPopulation() int { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "HumanPopulation") + ret0, _ := ret[0].(int) + return ret0 +} + +// HumanPopulation indicates an expected call of HumanPopulation. +func (mr *MockEarthMockRecorder) HumanPopulation() *MockEarthHumanPopulationCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HumanPopulation", reflect.TypeOf((*MockEarth)(nil).HumanPopulation)) + return &MockEarthHumanPopulationCall{Call: call} +} + +// MockEarthHumanPopulationCall wrap *gomock.Call +type MockEarthHumanPopulationCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockEarthHumanPopulationCall) Return(arg0 int) *MockEarthHumanPopulationCall { + c.Call = c.Call.Return(arg0) + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockEarthHumanPopulationCall) Do(f func() int) *MockEarthHumanPopulationCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockEarthHumanPopulationCall) DoAndReturn(f func() int) *MockEarthHumanPopulationCall { + c.Call = c.Call.DoAndReturn(f) + return c +} diff --git a/mockgen/internal/tests/package_mode/mock/interfaces_test.go b/mockgen/internal/tests/package_mode/mock/interfaces_test.go new file mode 100644 index 0000000..b47d605 --- /dev/null +++ b/mockgen/internal/tests/package_mode/mock/interfaces_test.go @@ -0,0 +1,41 @@ +package mock + +import ( + "testing" + + "go.uber.org/mock/gomock" + "go.uber.org/mock/mockgen/internal/tests/package_mode" + "go.uber.org/mock/mockgen/internal/tests/package_mode/cars" + "go.uber.org/mock/mockgen/internal/tests/package_mode/fuel" +) + +// checks, that mocks implement interfaces in compile-time. +// If something breaks, the tests will not be compiled. + +var food package_mode.Food = &MockFood{} + +var eater package_mode.Eater = &MockEater{} + +var animal package_mode.Animal = &MockAnimal{} + +var human package_mode.Human = &MockHuman{} + +var primate package_mode.Primate = &MockPrimate{} + +var car package_mode.Car[fuel.Gasoline] = &MockCar[fuel.Gasoline]{} + +var driver package_mode.Driver[fuel.Gasoline, cars.HyundaiSolaris] = &MockDriver[fuel.Gasoline, cars.HyundaiSolaris]{} + +var urbanResident package_mode.UrbanResident = &MockUrbanResident{} + +var farmer package_mode.Farmer = &MockFarmer{} + +func TestInterfaces(t *testing.T) { + ctrl := gomock.NewController(t) + + mock := NewMockFarmer(ctrl) + mock.EXPECT().Breathe() + + farmer := package_mode.Farmer(mock) + farmer.Breathe() +} diff --git a/mockgen/internal/tests/sanitization/mockout/mock.go b/mockgen/internal/tests/sanitization/mockout/mock.go index 345d2b8..7d72632 100644 --- a/mockgen/internal/tests/sanitization/mockout/mock.go +++ b/mockgen/internal/tests/sanitization/mockout/mock.go @@ -41,13 +41,13 @@ func (m *MockAnyMock) EXPECT() *MockAnyMockMockRecorder { } // Do mocks base method. -func (m *MockAnyMock) Do(arg0 *any0.Any, arg1 int) { +func (m *MockAnyMock) Do(a *any0.Any, b int) { m.ctrl.T.Helper() - m.ctrl.Call(m, "Do", arg0, arg1) + m.ctrl.Call(m, "Do", a, b) } // Do indicates an expected call of Do. -func (mr *MockAnyMockMockRecorder) Do(arg0, arg1 any) *gomock.Call { +func (mr *MockAnyMockMockRecorder) Do(a, b any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Do", reflect.TypeOf((*MockAnyMock)(nil).Do), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Do", reflect.TypeOf((*MockAnyMock)(nil).Do), a, b) } diff --git a/mockgen/mockgen.go b/mockgen/mockgen.go index 7e2fe25..75c831a 100644 --- a/mockgen/mockgen.go +++ b/mockgen/mockgen.go @@ -61,14 +61,14 @@ var ( selfPackage = flag.String("self_package", "", "The full package import path for the generated code. The purpose of this flag is to prevent import cycles in the generated code by trying to include its own package. This can happen if the mock's package is set to one of its inputs (usually the main one) and the output is stdio so mockgen cannot detect the final output package. Setting this flag will then tell mockgen which import to exclude.") writeCmdComment = flag.Bool("write_command_comment", true, "Writes the command used as a comment if true.") writePkgComment = flag.Bool("write_package_comment", true, "Writes package documentation comment (godoc) if true.") - writeSourceComment = flag.Bool("write_source_comment", true, "Writes original file (source mode) or interface names (reflect mode) comment if true.") + writeSourceComment = flag.Bool("write_source_comment", true, "Writes original file (source mode) or interface names (package mode) comment if true.") writeGenerateDirective = flag.Bool("write_generate_directive", false, "Add //go:generate directive to regenerate the mock") copyrightFile = flag.String("copyright_file", "", "Copyright file used to add copyright header") buildConstraint = flag.String("build_constraint", "", "If non-empty, added as //go:build ") typed = flag.Bool("typed", false, "Generate Type-safe 'Return', 'Do', 'DoAndReturn' function") imports = flag.String("imports", "", "(source mode) Comma-separated name=path pairs of explicit imports to use.") auxFiles = flag.String("aux_files", "", "(source mode) Comma-separated pkg=path pairs of auxiliary Go source files.") - excludeInterfaces = flag.String("exclude_interfaces", "", "Comma-separated names of interfaces to be excluded") + excludeInterfaces = flag.String("exclude_interfaces", "", "(source mode) Comma-separated names of interfaces to be excluded") debugParser = flag.Bool("debug_parser", false, "Print out parser results only.") showVersion = flag.Bool("version", false, "Print version.") @@ -78,6 +78,8 @@ func main() { flag.Usage = usage flag.Parse() + notifyAboutDeprecatedFlags() + if *showVersion { printVersion() return @@ -105,7 +107,8 @@ func main() { log.Fatalf("Parse package name failed: %v", err) } } - pkg, err = reflectMode(packageName, interfaces) + parser := packageModeParser{} + pkg, err = parser.parsePackage(packageName, interfaces) } if err != nil { log.Fatalf("Loading input failed: %v", err) @@ -118,7 +121,7 @@ func main() { outputPackageName := *packageOut if outputPackageName == "" { - // pkg.Name in reflect mode is the base name of the import path, + // pkg.Name in package mode is the base name of the import path, // which might have characters that are illegal to have in package names. outputPackageName = "mock_" + sanitize(pkg.Name) } @@ -229,20 +232,21 @@ func usage() { flag.PrintDefaults() } -const usageText = `mockgen has two modes of operation: source and reflect. +const usageText = `mockgen has two modes of operation: source and package. Source mode generates mock interfaces from a source file. It is enabled by using the -source flag. Other flags that -may be useful in this mode are -imports and -aux_files. +may be useful in this mode are -imports, -aux_files and -exclude_interfaces. Example: mockgen -source=foo.go [other options] -Reflect mode generates mock interfaces by building a program -that uses reflection to understand interfaces. It is enabled -by passing two non-flag arguments: an import path, and a -comma-separated list of symbols. +Package mode works by specifying the package and interface names. +It is enabled by passing two non-flag arguments: an import path, and a +comma-separated list of symbols. +You can use "." to refer to the current path's package. Example: mockgen database/sql/driver Conn,Driver + mockgen . SomeInterface ` diff --git a/mockgen/package_mode.go b/mockgen/package_mode.go new file mode 100644 index 0000000..abc9c7a --- /dev/null +++ b/mockgen/package_mode.go @@ -0,0 +1,358 @@ +package main + +import ( + "errors" + "flag" + "fmt" + "go/types" + "strings" + + "go.uber.org/mock/mockgen/model" + "golang.org/x/tools/go/packages" +) + +var ( + buildFlags = flag.String("build_flags", "", "(package mode) Additional flags for go build.") +) + +type packageModeParser struct { + pkgName string +} + +func (p *packageModeParser) parsePackage(packageName string, ifaces []string) (*model.Package, error) { + p.pkgName = packageName + + pkg, err := p.loadPackage(packageName) + if err != nil { + return nil, fmt.Errorf("load package: %w", err) + } + + interfaces, err := p.extractInterfacesFromPackage(pkg, ifaces) + if err != nil { + return nil, fmt.Errorf("extract interfaces from package: %w", err) + } + + return &model.Package{ + Name: pkg.Types.Name(), + PkgPath: packageName, + Interfaces: interfaces, + }, nil +} + +func (p *packageModeParser) loadPackage(packageName string) (*packages.Package, error) { + var buildFlagsSet []string + if *buildFlags != "" { + buildFlagsSet = strings.Split(*buildFlags, " ") + } + + cfg := &packages.Config{ + Mode: packages.NeedDeps | packages.NeedImports | packages.NeedTypes | packages.NeedTypesInfo | packages.NeedEmbedFiles, + BuildFlags: buildFlagsSet, + } + pkgs, err := packages.Load(cfg, packageName) + if err != nil { + return nil, fmt.Errorf("load packages: %w", err) + } + + if len(pkgs) != 1 { + return nil, fmt.Errorf("packages length must be 1: %d", len(pkgs)) + } + + if len(pkgs[0].Errors) > 0 { + errs := make([]error, len(pkgs[0].Errors)) + for i, err := range pkgs[0].Errors { + errs[i] = err + } + + return nil, errors.Join(errs...) + } + + return pkgs[0], nil +} + +func (p *packageModeParser) extractInterfacesFromPackage(pkg *packages.Package, ifaces []string) ([]*model.Interface, error) { + interfaces := make([]*model.Interface, len(ifaces)) + for i, iface := range ifaces { + obj := pkg.Types.Scope().Lookup(iface) + if obj == nil { + return nil, fmt.Errorf("interface %s does not exist", iface) + } + + modelIface, err := p.parseInterface(obj) + if err != nil { + return nil, newParseTypeError("parse interface", obj.Name(), err) + } + + interfaces[i] = modelIface + } + + return interfaces, nil +} + +func (p *packageModeParser) parseInterface(obj types.Object) (*model.Interface, error) { + named, ok := types.Unalias(obj.Type()).(*types.Named) + if !ok { + return nil, fmt.Errorf("%s is not an interface. it is a %T", obj.Name(), obj.Type().Underlying()) + } + + iface, ok := named.Underlying().(*types.Interface) + if !ok { + return nil, fmt.Errorf("%s is not an interface. it is a %T", obj.Name(), obj.Type().Underlying()) + } + + if p.isConstraint(iface) { + return nil, fmt.Errorf("interface %s is a constraint", obj.Name()) + } + + methods := make([]*model.Method, iface.NumMethods()) + for i := range iface.NumMethods() { + method := iface.Method(i) + typedMethod, ok := method.Type().(*types.Signature) + if !ok { + return nil, fmt.Errorf("method %s is not a signature", method.Name()) + } + + modelFunc, err := p.parseFunc(typedMethod) + if err != nil { + return nil, newParseTypeError("parse method", typedMethod.String(), err) + } + + methods[i] = &model.Method{ + Name: method.Name(), + In: modelFunc.In, + Out: modelFunc.Out, + Variadic: modelFunc.Variadic, + } + } + + if named.TypeParams() == nil { + return &model.Interface{Name: obj.Name(), Methods: methods}, nil + } + + typeParams := make([]*model.Parameter, named.TypeParams().Len()) + for i := range named.TypeParams().Len() { + param := named.TypeParams().At(i) + typeParam, err := p.parseConstraint(param) + if err != nil { + return nil, newParseTypeError("parse type parameter", param.String(), err) + } + + typeParams[i] = &model.Parameter{Name: param.Obj().Name(), Type: typeParam} + } + + return &model.Interface{Name: obj.Name(), Methods: methods, TypeParams: typeParams}, nil +} + +func (o *packageModeParser) isConstraint(t *types.Interface) bool { + for i := range t.NumEmbeddeds() { + embed := t.EmbeddedType(i) + if _, ok := embed.Underlying().(*types.Interface); !ok { + return true + } + } + + return false +} + +func (p *packageModeParser) parseType(t types.Type) (model.Type, error) { + switch t := t.(type) { + case *types.Array: + elementType, err := p.parseType(t.Elem()) + if err != nil { + return nil, newParseTypeError("parse array type", t.Elem().String(), err) + } + return &model.ArrayType{Len: int(t.Len()), Type: elementType}, nil + case *types.Slice: + elementType, err := p.parseType(t.Elem()) + if err != nil { + return nil, newParseTypeError("parse slice type", t.Elem().String(), err) + } + + return &model.ArrayType{Len: -1, Type: elementType}, nil + case *types.Chan: + var dir model.ChanDir + switch t.Dir() { + case types.RecvOnly: + dir = model.RecvDir + case types.SendOnly: + dir = model.SendDir + } + + chanType, err := p.parseType(t.Elem()) + if err != nil { + return nil, newParseTypeError("parse chan type", t.Elem().String(), err) + } + + return &model.ChanType{Dir: dir, Type: chanType}, nil + case *types.Signature: + sig, err := p.parseFunc(t) + if err != nil { + return nil, newParseTypeError("parse signature", t.String(), err) + } + + return sig, nil + case *types.Named, *types.Alias: + object := t.(interface{ Obj() *types.TypeName }) + var pkg string + if object.Obj().Pkg() != nil { + pkg = object.Obj().Pkg().Path() + } + + // TypeArgs method not available for aliases in go1.22 + genericType, ok := t.(interface{ TypeArgs() *types.TypeList }) + if !ok || genericType.TypeArgs() == nil { + return &model.NamedType{ + Package: pkg, + Type: object.Obj().Name(), + }, nil + } + + typeParams := &model.TypeParametersType{TypeParameters: make([]model.Type, genericType.TypeArgs().Len())} + for i := range genericType.TypeArgs().Len() { + typeParam := genericType.TypeArgs().At(i) + typedParam, err := p.parseType(typeParam) + if err != nil { + return nil, newParseTypeError("parse type parameter", typeParam.String(), err) + } + + typeParams.TypeParameters[i] = typedParam + } + + return &model.NamedType{ + Package: pkg, + Type: object.Obj().Name(), + TypeParams: typeParams, + }, nil + case *types.Interface: + if t.Empty() { + return model.PredeclaredType("any"), nil + } + + return nil, fmt.Errorf("cannot handle non-empty unnamed interfaces") + case *types.Map: + key, err := p.parseType(t.Key()) + if err != nil { + return nil, newParseTypeError("parse map key", t.Key().String(), err) + } + value, err := p.parseType(t.Elem()) + if err != nil { + return nil, newParseTypeError("parse map value", t.Elem().String(), err) + } + + return &model.MapType{Key: key, Value: value}, nil + case *types.Pointer: + valueType, err := p.parseType(t.Elem()) + if err != nil { + return nil, newParseTypeError("parse pointer type", t.Elem().String(), err) + } + + return &model.PointerType{Type: valueType}, nil + case *types.Struct: + if t.NumFields() > 0 { + return nil, fmt.Errorf("cannot handle non-empty unnamed structs") + } + + return model.PredeclaredType("struct{}"), nil + case *types.Basic: + return model.PredeclaredType(t.Name()), nil + case *types.Tuple: + panic("tuple field") // TODO + case *types.TypeParam: + return &model.NamedType{Type: t.Obj().Name()}, nil + default: + panic("unknown type") // TODO + } +} + +func (p *packageModeParser) parseFunc(sig *types.Signature) (*model.FuncType, error) { + var variadic *model.Parameter + params := make([]*model.Parameter, 0, sig.Params().Len()) + for i := range sig.Params().Len() { + param := sig.Params().At(i) + + isVariadicParam := i == sig.Params().Len()-1 && sig.Variadic() + parseType := param.Type() + if isVariadicParam { + sliceType, ok := param.Type().(*types.Slice) + if !ok { + return nil, newParseTypeError("variadic parameter is not a slice", param.String(), nil) + } + + parseType = sliceType.Elem() + } + + paramType, err := p.parseType(parseType) + if err != nil { + return nil, newParseTypeError("parse parameter type", parseType.String(), err) + } + + modelParameter := &model.Parameter{Type: paramType, Name: param.Name()} + + if isVariadicParam { + variadic = modelParameter + } else { + params = append(params, modelParameter) + } + } + + if len(params) == 0 { + params = nil + } + + results := make([]*model.Parameter, sig.Results().Len()) + for i := range sig.Results().Len() { + result := sig.Results().At(i) + + resultType, err := p.parseType(result.Type()) + if err != nil { + return nil, newParseTypeError("parse result type", result.Type().String(), err) + } + + results[i] = &model.Parameter{Type: resultType, Name: result.Name()} + } + + if len(results) == 0 { + results = nil + } + + return &model.FuncType{ + In: params, + Out: results, + Variadic: variadic, + }, nil +} + +func (p *packageModeParser) parseConstraint(t *types.TypeParam) (model.Type, error) { + if t == nil { + return nil, fmt.Errorf("nil type param") + } + + typeParam, err := p.parseType(t.Constraint()) + if err != nil { + return nil, newParseTypeError("parse constraint type", t.Constraint().String(), err) + } + + return typeParam, nil +} + +type parseTypeError struct { + message string + typeString string + error error +} + +func newParseTypeError(message string, typeString string, error error) *parseTypeError { + return &parseTypeError{typeString: typeString, error: error, message: message} +} + +func (p parseTypeError) Error() string { + if p.error != nil { + return fmt.Sprintf("%s: error parsing %s: %s", p.message, p.typeString, p.error) + } + + return fmt.Sprintf("%s: error parsing type %s", p.message, p.typeString) +} + +func (p parseTypeError) Unwrap() error { + return p.error +} diff --git a/mockgen/package_mode_test.go b/mockgen/package_mode_test.go new file mode 100644 index 0000000..5db836f --- /dev/null +++ b/mockgen/package_mode_test.go @@ -0,0 +1,360 @@ +package main + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "go.uber.org/mock/mockgen/model" +) + +func Test_packageModeParser_parsePackage(t *testing.T) { + type args struct { + packageName string + ifaces []string + } + tests := []struct { + name string + args args + expected *model.Package + expectedErr string + }{ + { + name: "error: no found package", + args: args{ + packageName: "foo/bar/another_package", + ifaces: []string{"Human"}, + }, + expectedErr: "load package: -: package foo/bar/another_package is not in std", + }, + { + name: "error: interface does not exist", + args: args{ + packageName: "go.uber.org/mock/mockgen/internal/tests/package_mode", + ifaces: []string{"Alien"}, + }, + expectedErr: "extract interfaces from package: interface Alien does not exist", + }, + { + name: "error: search for struct instead of interface", + args: args{ + packageName: "go.uber.org/mock/mockgen/internal/tests/package_mode", + ifaces: []string{"Work"}, + }, + expectedErr: "extract interfaces from package: parse interface: " + + "error parsing Work: " + + "Work is not an interface. it is a *types.Struct", + }, + { + name: "error: search for constraint instead of interface", + args: args{ + packageName: "go.uber.org/mock/mockgen/internal/tests/package_mode", + ifaces: []string{"Counter"}, + }, + expectedErr: "extract interfaces from package: parse interface: " + + "error parsing Counter: " + + "interface Counter is a constraint", + }, + { + name: "success: simple interface", + args: args{ + packageName: "go.uber.org/mock/mockgen/internal/tests/package_mode", + ifaces: []string{"Food"}, + }, + expected: &model.Package{ + Name: "package_mode", + PkgPath: "go.uber.org/mock/mockgen/internal/tests/package_mode", + Interfaces: []*model.Interface{ + { + Name: "Food", + Methods: []*model.Method{ + { + Name: "Calories", + Out: []*model.Parameter{ + {Type: model.PredeclaredType("int")}, + }, + }, + }, + }, + }, + }, + }, + { + name: "success: interface with variadic args", + args: args{ + packageName: "go.uber.org/mock/mockgen/internal/tests/package_mode", + ifaces: []string{"Eater"}, + }, + expected: &model.Package{ + Name: "package_mode", + PkgPath: "go.uber.org/mock/mockgen/internal/tests/package_mode", + Interfaces: []*model.Interface{ + { + Name: "Eater", + Methods: []*model.Method{ + { + Name: "Eat", + Variadic: &model.Parameter{ + Name: "foods", + Type: &model.NamedType{ + Package: "go.uber.org/mock/mockgen/internal/tests/package_mode", + Type: "Food", + }, + }, + }, + }, + }, + }, + }, + }, + { + name: "success: interface with generic", + args: args{ + packageName: "go.uber.org/mock/mockgen/internal/tests/package_mode", + ifaces: []string{"Car"}, + }, + expected: &model.Package{ + Name: "package_mode", + PkgPath: "go.uber.org/mock/mockgen/internal/tests/package_mode", + Interfaces: []*model.Interface{ + { + Name: "Car", + Methods: []*model.Method{ + { + Name: "Brand", + Out: []*model.Parameter{ + {Type: model.PredeclaredType("string")}, + }, + }, + { + Name: "FuelTank", + Out: []*model.Parameter{ + { + Type: &model.NamedType{ + Package: "go.uber.org/mock/mockgen/internal/tests/package_mode/cars", + Type: "FuelTank", + TypeParams: &model.TypeParametersType{ + TypeParameters: []model.Type{ + &model.NamedType{ + Type: "FuelType", + }, + }, + }, + }, + }, + }, + }, + { + Name: "Refuel", + In: []*model.Parameter{ + { + Name: "fuel", + Type: &model.NamedType{Type: "FuelType"}, + }, + { + Name: "volume", + Type: model.PredeclaredType("int"), + }, + }, + Out: []*model.Parameter{ + {Type: &model.NamedType{Type: "error"}}, + }, + }, + }, + TypeParams: []*model.Parameter{ + { + Name: "FuelType", + Type: &model.NamedType{ + Package: "go.uber.org/mock/mockgen/internal/tests/package_mode/fuel", + Type: "Fuel", + }, + }, + }, + }, + }, + }, + }, + { + name: "success: interface with embedded interfaces", + args: args{ + packageName: "go.uber.org/mock/mockgen/internal/tests/package_mode", + ifaces: []string{"Animal"}, + }, + expected: &model.Package{ + Name: "package_mode", + PkgPath: "go.uber.org/mock/mockgen/internal/tests/package_mode", + Interfaces: []*model.Interface{ + { + Name: "Animal", + Methods: []*model.Method{ + {Name: "Breathe"}, + { + Name: "Eat", + Variadic: &model.Parameter{ + Name: "foods", + Type: &model.NamedType{ + Package: "go.uber.org/mock/mockgen/internal/tests/package_mode", + Type: "Food", + }, + }, + }, + { + Name: "Sleep", + In: []*model.Parameter{ + { + Name: "duration", + Type: &model.NamedType{ + Package: "time", + Type: "Duration", + }, + }, + }, + }, + }, + }, + }, + }, + }, + { + name: "success: subtype of interface", + args: args{ + packageName: "go.uber.org/mock/mockgen/internal/tests/package_mode", + ifaces: []string{"Primate"}, + }, + expected: &model.Package{ + Name: "package_mode", + PkgPath: "go.uber.org/mock/mockgen/internal/tests/package_mode", + Interfaces: []*model.Interface{ + { + Name: "Primate", + Methods: []*model.Method{ + {Name: "Breathe"}, + { + Name: "Eat", + Variadic: &model.Parameter{ + Name: "foods", + Type: &model.NamedType{ + Package: "go.uber.org/mock/mockgen/internal/tests/package_mode", + Type: "Food", + }, + }, + }, + { + Name: "Sleep", + In: []*model.Parameter{ + { + Name: "duration", + Type: &model.NamedType{ + Package: "time", + Type: "Duration", + }, + }, + }, + }, + }, + }, + }, + }, + }, + { + name: "success: alias to interface", + args: args{ + packageName: "go.uber.org/mock/mockgen/internal/tests/package_mode", + ifaces: []string{"Human"}, + }, + expected: &model.Package{ + Name: "package_mode", + PkgPath: "go.uber.org/mock/mockgen/internal/tests/package_mode", + Interfaces: []*model.Interface{ + { + Name: "Human", + Methods: []*model.Method{ + {Name: "Breathe"}, + { + Name: "Eat", + Variadic: &model.Parameter{ + Name: "foods", + Type: &model.NamedType{ + Package: "go.uber.org/mock/mockgen/internal/tests/package_mode", + Type: "Food", + }, + }, + }, + { + Name: "Sleep", + In: []*model.Parameter{ + { + Name: "duration", + Type: &model.NamedType{ + Package: "time", + Type: "Duration", + }, + }, + }, + }, + }, + }, + }, + }, + }, + { + name: "success: interfaces with aliases in params and returns", + args: args{ + packageName: "go.uber.org/mock/mockgen/internal/tests/package_mode", + ifaces: []string{"Earth"}, + }, + expected: &model.Package{ + Name: "package_mode", + PkgPath: "go.uber.org/mock/mockgen/internal/tests/package_mode", + Interfaces: []*model.Interface{ + { + Name: "Earth", + Methods: []*model.Method{ + { + Name: "AddHumans", + In: []*model.Parameter{ + { + Type: model.PredeclaredType("int"), + }, + }, + Out: []*model.Parameter{ + { + Type: &model.ArrayType{ + Len: -1, // slice + Type: &model.NamedType{ + Package: "go.uber.org/mock/mockgen/internal/tests/package_mode", + Type: "Primate", + }, + }, + }, + }, + }, + { + Name: "HumanPopulation", + Out: []*model.Parameter{ + { + Type: model.PredeclaredType("int"), + }, + }, + }, + }, + }, + }, + }, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + parser := packageModeParser{} + actual, err := parser.parsePackage(tt.args.packageName, tt.args.ifaces) + + if tt.expectedErr != "" { + assert.ErrorContains(t, err, tt.expectedErr) + } else { + assert.NoError(t, err) + } + + assert.Equal(t, tt.expected, actual) + }) + } +} diff --git a/mockgen/reflect.go b/mockgen/reflect.go deleted file mode 100644 index 68d922b..0000000 --- a/mockgen/reflect.go +++ /dev/null @@ -1,256 +0,0 @@ -// Copyright 2012 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package main - -// This file contains the model construction by reflection. - -import ( - "bytes" - "encoding/gob" - "flag" - "fmt" - "go/build" - "io" - "log" - "os" - "os/exec" - "path/filepath" - "runtime" - "strings" - "text/template" - - "go.uber.org/mock/mockgen/model" -) - -var ( - progOnly = flag.Bool("prog_only", false, "(reflect mode) Only generate the reflection program; write it to stdout and exit.") - execOnly = flag.String("exec_only", "", "(reflect mode) If set, execute this reflection program.") - buildFlags = flag.String("build_flags", "", "(reflect mode) Additional flags for go build.") -) - -// reflectMode generates mocks via reflection on an interface. -func reflectMode(importPath string, symbols []string) (*model.Package, error) { - if *execOnly != "" { - return run(*execOnly) - } - - program, err := writeProgram(importPath, symbols) - if err != nil { - return nil, err - } - - if *progOnly { - if _, err := os.Stdout.Write(program); err != nil { - return nil, err - } - os.Exit(0) - } - - wd, _ := os.Getwd() - - // Try to run the reflection program in the current working directory. - if p, err := runInDir(program, wd); err == nil { - return p, nil - } - - // Try to run the program in the same directory as the input package. - if p, err := build.Import(importPath, wd, build.FindOnly); err == nil { - dir := p.Dir - if p, err := runInDir(program, dir); err == nil { - return p, nil - } - } - - // Try to run it in a standard temp directory. - return runInDir(program, "") -} - -func writeProgram(importPath string, symbols []string) ([]byte, error) { - var program bytes.Buffer - data := reflectData{ - ImportPath: importPath, - Symbols: symbols, - } - if err := reflectProgram.Execute(&program, &data); err != nil { - return nil, err - } - return program.Bytes(), nil -} - -// run the given program and parse the output as a model.Package. -func run(program string) (*model.Package, error) { - f, err := os.CreateTemp("", "") - if err != nil { - return nil, err - } - - filename := f.Name() - defer os.Remove(filename) - if err := f.Close(); err != nil { - return nil, err - } - - // Run the program. - cmd := exec.Command(program, "-output", filename) - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - if err := cmd.Run(); err != nil { - return nil, err - } - - f, err = os.Open(filename) - if err != nil { - return nil, err - } - - // Process output. - var pkg model.Package - if err := gob.NewDecoder(f).Decode(&pkg); err != nil { - return nil, err - } - - if err := f.Close(); err != nil { - return nil, err - } - - return &pkg, nil -} - -// runInDir writes the given program into the given dir, runs it there, and -// parses the output as a model.Package. -func runInDir(program []byte, dir string) (*model.Package, error) { - // We use TempDir instead of TempFile so we can control the filename. - tmpDir, err := os.MkdirTemp(dir, "gomock_reflect_") - if err != nil { - return nil, err - } - defer func() { - if err := os.RemoveAll(tmpDir); err != nil { - log.Printf("failed to remove temp directory: %s", err) - } - }() - const progSource = "prog.go" - progBinary := "prog.bin" - if runtime.GOOS == "windows" { - // Windows won't execute a program unless it has a ".exe" suffix. - progBinary += ".exe" - } - - if err := os.WriteFile(filepath.Join(tmpDir, progSource), program, 0o600); err != nil { - return nil, err - } - - cmdArgs := []string{} - cmdArgs = append(cmdArgs, "build") - if *buildFlags != "" { - cmdArgs = append(cmdArgs, strings.Split(*buildFlags, " ")...) - } - cmdArgs = append(cmdArgs, "-o", progBinary, progSource) - - // Build the program. - buf := bytes.NewBuffer(nil) - cmd := exec.Command("go", cmdArgs...) - cmd.Dir = tmpDir - cmd.Stdout = os.Stdout - cmd.Stderr = io.MultiWriter(os.Stderr, buf) - if err := cmd.Run(); err != nil { - sErr := buf.String() - if strings.Contains(sErr, `cannot find package "."`) && - strings.Contains(sErr, "go.uber.org/mock/mockgen/model") { - fmt.Fprint(os.Stderr, "Please reference the steps in the README to fix this error:\n\thttps://go.uber.org/mock#reflect-vendoring-error.\n") - return nil, err - } - return nil, err - } - - return run(filepath.Join(tmpDir, progBinary)) -} - -type reflectData struct { - ImportPath string - Symbols []string -} - -// This program reflects on an interface value, and prints the -// gob encoding of a model.Package to standard output. -// JSON doesn't work because of the model.Type interface. -var reflectProgram = template.Must(template.New("program").Parse(` -// Code generated by MockGen. DO NOT EDIT. -package main - -import ( - "encoding/gob" - "flag" - "fmt" - "os" - "path" - "reflect" - - "go.uber.org/mock/mockgen/model" - - pkg_ {{printf "%q" .ImportPath}} -) - -var output = flag.String("output", "", "The output file name, or empty to use stdout.") - -func main() { - flag.Parse() - - its := []struct{ - sym string - typ reflect.Type - }{ - {{range .Symbols}} - { {{printf "%q" .}}, reflect.TypeOf((*pkg_.{{.}})(nil)).Elem()}, - {{end}} - } - pkg := &model.Package{ - // NOTE: This behaves contrary to documented behaviour if the - // package name is not the final component of the import path. - // The reflect package doesn't expose the package name, though. - Name: path.Base({{printf "%q" .ImportPath}}), - } - - for _, it := range its { - intf, err := model.InterfaceFromInterfaceType(it.typ) - if err != nil { - fmt.Fprintf(os.Stderr, "Reflection: %v\n", err) - os.Exit(1) - } - intf.Name = it.sym - pkg.Interfaces = append(pkg.Interfaces, intf) - } - - outfile := os.Stdout - if len(*output) != 0 { - var err error - outfile, err = os.Create(*output) - if err != nil { - fmt.Fprintf(os.Stderr, "failed to open output file %q", *output) - } - defer func() { - if err := outfile.Close(); err != nil { - fmt.Fprintf(os.Stderr, "failed to close output file %q", *output) - os.Exit(1) - } - }() - } - - if err := gob.NewEncoder(outfile).Encode(pkg); err != nil { - fmt.Fprintf(os.Stderr, "gob encode: %v\n", err) - os.Exit(1) - } -} -`)) diff --git a/sample/concurrent/mock/concurrent_mock.go b/sample/concurrent/mock/concurrent_mock.go index eb6bb28..2adee96 100644 --- a/sample/concurrent/mock/concurrent_mock.go +++ b/sample/concurrent/mock/concurrent_mock.go @@ -40,15 +40,15 @@ func (m *MockMath) EXPECT() *MockMathMockRecorder { } // Sum mocks base method. -func (m *MockMath) Sum(arg0, arg1 int) int { +func (m *MockMath) Sum(a, b int) int { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Sum", arg0, arg1) + ret := m.ctrl.Call(m, "Sum", a, b) ret0, _ := ret[0].(int) return ret0 } // Sum indicates an expected call of Sum. -func (mr *MockMathMockRecorder) Sum(arg0, arg1 any) *gomock.Call { +func (mr *MockMathMockRecorder) Sum(a, b any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Sum", reflect.TypeOf((*MockMath)(nil).Sum), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Sum", reflect.TypeOf((*MockMath)(nil).Sum), a, b) } diff --git a/sample/mock_user_test.go b/sample/mock_user_test.go index 7c48043..94c1acc 100644 --- a/sample/mock_user_test.go +++ b/sample/mock_user_test.go @@ -63,15 +63,15 @@ func (mr *MockIndexMockRecorder) Anon(arg0 any) *gomock.Call { } // Chan mocks base method. -func (m *MockIndex) Chan(arg0 chan int, arg1 chan<- hash.Hash) { +func (m *MockIndex) Chan(a chan int, b chan<- hash.Hash) { m.ctrl.T.Helper() - m.ctrl.Call(m, "Chan", arg0, arg1) + m.ctrl.Call(m, "Chan", a, b) } // Chan indicates an expected call of Chan. -func (mr *MockIndexMockRecorder) Chan(arg0, arg1 any) *gomock.Call { +func (mr *MockIndexMockRecorder) Chan(a, b any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Chan", reflect.TypeOf((*MockIndex)(nil).Chan), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Chan", reflect.TypeOf((*MockIndex)(nil).Chan), a, b) } // ConcreteRet mocks base method. @@ -89,19 +89,19 @@ func (mr *MockIndexMockRecorder) ConcreteRet() *gomock.Call { } // Ellip mocks base method. -func (m *MockIndex) Ellip(arg0 string, arg1 ...any) { +func (m *MockIndex) Ellip(fmt string, args ...any) { m.ctrl.T.Helper() - varargs := []any{arg0} - for _, a := range arg1 { + varargs := []any{fmt} + for _, a := range args { varargs = append(varargs, a) } m.ctrl.Call(m, "Ellip", varargs...) } // Ellip indicates an expected call of Ellip. -func (mr *MockIndexMockRecorder) Ellip(arg0 any, arg1 ...any) *gomock.Call { +func (mr *MockIndexMockRecorder) Ellip(fmt any, args ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]any{arg0}, arg1...) + varargs := append([]any{fmt}, args...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Ellip", reflect.TypeOf((*MockIndex)(nil).Ellip), varargs...) } @@ -170,56 +170,56 @@ func (mr *MockIndexMockRecorder) ForeignTwo(arg0 any) *gomock.Call { } // Func mocks base method. -func (m *MockIndex) Func(arg0 func(http.Request) (int, bool)) { +func (m *MockIndex) Func(f func(http.Request) (int, bool)) { m.ctrl.T.Helper() - m.ctrl.Call(m, "Func", arg0) + m.ctrl.Call(m, "Func", f) } // Func indicates an expected call of Func. -func (mr *MockIndexMockRecorder) Func(arg0 any) *gomock.Call { +func (mr *MockIndexMockRecorder) Func(f any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Func", reflect.TypeOf((*MockIndex)(nil).Func), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Func", reflect.TypeOf((*MockIndex)(nil).Func), f) } // Get mocks base method. -func (m *MockIndex) Get(arg0 string) any { +func (m *MockIndex) Get(key string) any { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Get", arg0) + ret := m.ctrl.Call(m, "Get", key) ret0, _ := ret[0].(any) return ret0 } // Get indicates an expected call of Get. -func (mr *MockIndexMockRecorder) Get(arg0 any) *gomock.Call { +func (mr *MockIndexMockRecorder) Get(key any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockIndex)(nil).Get), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockIndex)(nil).Get), key) } // GetTwo mocks base method. -func (m *MockIndex) GetTwo(arg0, arg1 string) (any, any) { +func (m *MockIndex) GetTwo(key1, key2 string) (any, any) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetTwo", arg0, arg1) + ret := m.ctrl.Call(m, "GetTwo", key1, key2) ret0, _ := ret[0].(any) ret1, _ := ret[1].(any) return ret0, ret1 } // GetTwo indicates an expected call of GetTwo. -func (mr *MockIndexMockRecorder) GetTwo(arg0, arg1 any) *gomock.Call { +func (mr *MockIndexMockRecorder) GetTwo(key1, key2 any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTwo", reflect.TypeOf((*MockIndex)(nil).GetTwo), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTwo", reflect.TypeOf((*MockIndex)(nil).GetTwo), key1, key2) } // Map mocks base method. -func (m *MockIndex) Map(arg0 map[int]hash.Hash) { +func (m *MockIndex) Map(a map[int]hash.Hash) { m.ctrl.T.Helper() - m.ctrl.Call(m, "Map", arg0) + m.ctrl.Call(m, "Map", a) } // Map indicates an expected call of Map. -func (mr *MockIndexMockRecorder) Map(arg0 any) *gomock.Call { +func (mr *MockIndexMockRecorder) Map(a any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Map", reflect.TypeOf((*MockIndex)(nil).Map), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Map", reflect.TypeOf((*MockIndex)(nil).Map), a) } // NillableRet mocks base method. @@ -251,89 +251,89 @@ func (mr *MockIndexMockRecorder) Other() *gomock.Call { } // Ptr mocks base method. -func (m *MockIndex) Ptr(arg0 *int) { +func (m *MockIndex) Ptr(arg *int) { m.ctrl.T.Helper() - m.ctrl.Call(m, "Ptr", arg0) + m.ctrl.Call(m, "Ptr", arg) } // Ptr indicates an expected call of Ptr. -func (mr *MockIndexMockRecorder) Ptr(arg0 any) *gomock.Call { +func (mr *MockIndexMockRecorder) Ptr(arg any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Ptr", reflect.TypeOf((*MockIndex)(nil).Ptr), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Ptr", reflect.TypeOf((*MockIndex)(nil).Ptr), arg) } // Put mocks base method. -func (m *MockIndex) Put(arg0 string, arg1 any) { +func (m *MockIndex) Put(key string, value any) { m.ctrl.T.Helper() - m.ctrl.Call(m, "Put", arg0, arg1) + m.ctrl.Call(m, "Put", key, value) } // Put indicates an expected call of Put. -func (mr *MockIndexMockRecorder) Put(arg0, arg1 any) *gomock.Call { +func (mr *MockIndexMockRecorder) Put(key, value any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Put", reflect.TypeOf((*MockIndex)(nil).Put), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Put", reflect.TypeOf((*MockIndex)(nil).Put), key, value) } // Slice mocks base method. -func (m *MockIndex) Slice(arg0 []int, arg1 []byte) [3]int { +func (m *MockIndex) Slice(a []int, b []byte) [3]int { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Slice", arg0, arg1) + ret := m.ctrl.Call(m, "Slice", a, b) ret0, _ := ret[0].([3]int) return ret0 } // Slice indicates an expected call of Slice. -func (mr *MockIndexMockRecorder) Slice(arg0, arg1 any) *gomock.Call { +func (mr *MockIndexMockRecorder) Slice(a, b any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Slice", reflect.TypeOf((*MockIndex)(nil).Slice), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Slice", reflect.TypeOf((*MockIndex)(nil).Slice), a, b) } // Struct mocks base method. -func (m *MockIndex) Struct(arg0 struct{}) { +func (m *MockIndex) Struct(a struct{}) { m.ctrl.T.Helper() - m.ctrl.Call(m, "Struct", arg0) + m.ctrl.Call(m, "Struct", a) } // Struct indicates an expected call of Struct. -func (mr *MockIndexMockRecorder) Struct(arg0 any) *gomock.Call { +func (mr *MockIndexMockRecorder) Struct(a any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Struct", reflect.TypeOf((*MockIndex)(nil).Struct), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Struct", reflect.TypeOf((*MockIndex)(nil).Struct), a) } // StructChan mocks base method. -func (m *MockIndex) StructChan(arg0 chan struct{}) { +func (m *MockIndex) StructChan(a chan struct{}) { m.ctrl.T.Helper() - m.ctrl.Call(m, "StructChan", arg0) + m.ctrl.Call(m, "StructChan", a) } // StructChan indicates an expected call of StructChan. -func (mr *MockIndexMockRecorder) StructChan(arg0 any) *gomock.Call { +func (mr *MockIndexMockRecorder) StructChan(a any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StructChan", reflect.TypeOf((*MockIndex)(nil).StructChan), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StructChan", reflect.TypeOf((*MockIndex)(nil).StructChan), a) } // Summary mocks base method. -func (m *MockIndex) Summary(arg0 *bytes.Buffer, arg1 io.Writer) { +func (m *MockIndex) Summary(buf *bytes.Buffer, w io.Writer) { m.ctrl.T.Helper() - m.ctrl.Call(m, "Summary", arg0, arg1) + m.ctrl.Call(m, "Summary", buf, w) } // Summary indicates an expected call of Summary. -func (mr *MockIndexMockRecorder) Summary(arg0, arg1 any) *gomock.Call { +func (mr *MockIndexMockRecorder) Summary(buf, w any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Summary", reflect.TypeOf((*MockIndex)(nil).Summary), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Summary", reflect.TypeOf((*MockIndex)(nil).Summary), buf, w) } // Templates mocks base method. -func (m *MockIndex) Templates(arg0 template.CSS, arg1 template0.FuncMap) { +func (m *MockIndex) Templates(a template.CSS, b template0.FuncMap) { m.ctrl.T.Helper() - m.ctrl.Call(m, "Templates", arg0, arg1) + m.ctrl.Call(m, "Templates", a, b) } // Templates indicates an expected call of Templates. -func (mr *MockIndexMockRecorder) Templates(arg0, arg1 any) *gomock.Call { +func (mr *MockIndexMockRecorder) Templates(a, b any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Templates", reflect.TypeOf((*MockIndex)(nil).Templates), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Templates", reflect.TypeOf((*MockIndex)(nil).Templates), a, b) } // MockEmbed is a mock of Embed interface. @@ -387,15 +387,15 @@ func (mr *MockEmbedMockRecorder) ForeignEmbeddedMethod() *gomock.Call { } // ImplicitPackage mocks base method. -func (m *MockEmbed) ImplicitPackage(arg0 string, arg1 imp1.ImpT, arg2 []imp1.ImpT, arg3 *imp1.ImpT, arg4 chan imp1.ImpT) { +func (m *MockEmbed) ImplicitPackage(s string, t imp1.ImpT, st []imp1.ImpT, pt *imp1.ImpT, ct chan imp1.ImpT) { m.ctrl.T.Helper() - m.ctrl.Call(m, "ImplicitPackage", arg0, arg1, arg2, arg3, arg4) + m.ctrl.Call(m, "ImplicitPackage", s, t, st, pt, ct) } // ImplicitPackage indicates an expected call of ImplicitPackage. -func (mr *MockEmbedMockRecorder) ImplicitPackage(arg0, arg1, arg2, arg3, arg4 any) *gomock.Call { +func (mr *MockEmbedMockRecorder) ImplicitPackage(s, t, st, pt, ct any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ImplicitPackage", reflect.TypeOf((*MockEmbed)(nil).ImplicitPackage), arg0, arg1, arg2, arg3, arg4) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ImplicitPackage", reflect.TypeOf((*MockEmbed)(nil).ImplicitPackage), s, t, st, pt, ct) } // RegularMethod mocks base method.