From bd617013eb518732e176b1a0633af6a880cb55c1 Mon Sep 17 00:00:00 2001
From: LandonTClipp <11232769+LandonTClipp@users.noreply.github.com>
Date: Thu, 2 Jan 2025 12:51:05 -0600
Subject: [PATCH] Lots of cleanup
---
.mockery.yml | 65 +---
Taskfile.yml | 2 +-
docs/templates.md | 92 ++---
internal/config.go | 12 +-
.../fixtures/buildtag/comment/mocks_test.go | 233 +++++++++++
internal/fixtures/empty_return/interface.go | 2 +-
.../fixtures/empty_return/interface_test.go | 4 +-
.../empty_return/mock_EmptyReturn_test.go | 117 ------
internal/fixtures/empty_return/mocks_test.go | 117 ++++++
.../example_project/mock_stringer_test.go | 91 -----
.../{mock_root_test.go => mocks_test.go} | 81 +++-
.../example_project/replace_type/rt.go | 4 +-
.../fixtures/example_project/string_test.go | 5 +-
internal/fixtures/{test => }/expecter_test.go | 3 +-
.../iface_new_type/iface_new_type_test.go | 2 +-
...{mock_interface1_test.go => mocks_test.go} | 2 +-
.../fixtures/iface_typed_param/main_test.go | 2 +-
...face_typed_param_test.go => mocks_test.go} | 2 +-
.../index_list_expression_test.go | 2 +-
.../mock_index_list_expr_test.go | 93 -----
...c_multiple_types_test.go => mocks_test.go} | 83 +++-
.../fixtures/issue845/mock_WithFix_test.go | 91 -----
.../fixtures/{test => }/issue_766_test.go | 7 +-
.../same_name_arg_and_type/entity_test.go | 15 +-
.../mock_interfaceA_test.go | 200 ----------
.../mock_interfaceB0_test.go | 94 -----
.../mock_interfaceB_test.go | 91 -----
.../same_name_arg_and_type/mocks_test.go | 361 ++++++++++++++++++
internal/fixtures/{mocks.go => mocks_test.go} | 0
.../{Foo_mock.go => mocks_test.go} | 0
.../recursive_generation/subpkg1/Foo_mock.go | 91 -----
.../recursive_generation/subpkg2/Foo_mock.go | 91 -----
.../Foo_mock.go | 91 -----
.../type_alias/mock_Interface1_test.go | 92 -----
.../type_alias/mock_Interface2_test.go | 83 ----
internal/fixtures/type_alias/mocks_test.go | 161 ++++++++
.../{test => }/variadic_return_func_test.go | 3 +-
internal/template_generator.go | 6 +-
mockery-tools.env | 2 +-
.../IfaceWithCustomBuildTagInComment_mock.go | 143 -------
registry/method_scope.go | 51 ++-
template/template_data.go | 15 +-
42 files changed, 1129 insertions(+), 1573 deletions(-)
create mode 100644 internal/fixtures/buildtag/comment/mocks_test.go
delete mode 100644 internal/fixtures/empty_return/mock_EmptyReturn_test.go
create mode 100644 internal/fixtures/empty_return/mocks_test.go
delete mode 100644 internal/fixtures/example_project/mock_stringer_test.go
rename internal/fixtures/example_project/{mock_root_test.go => mocks_test.go} (63%)
rename internal/fixtures/{test => }/expecter_test.go (97%)
rename internal/fixtures/iface_new_type/{mock_interface1_test.go => mocks_test.go} (98%)
rename internal/fixtures/iface_typed_param/{mock_getter_iface_typed_param_test.go => mocks_test.go} (98%)
delete mode 100644 internal/fixtures/index_list_expr/mock_index_list_expr_test.go
rename internal/fixtures/index_list_expr/{mock_generic_multiple_types_test.go => mocks_test.go} (55%)
delete mode 100644 internal/fixtures/issue845/mock_WithFix_test.go
rename internal/fixtures/{test => }/issue_766_test.go (72%)
delete mode 100644 internal/fixtures/method_args/same_name_arg_and_type/mock_interfaceA_test.go
delete mode 100644 internal/fixtures/method_args/same_name_arg_and_type/mock_interfaceB0_test.go
delete mode 100644 internal/fixtures/method_args/same_name_arg_and_type/mock_interfaceB_test.go
create mode 100644 internal/fixtures/method_args/same_name_arg_and_type/mocks_test.go
rename internal/fixtures/{mocks.go => mocks_test.go} (100%)
rename internal/fixtures/recursive_generation/{Foo_mock.go => mocks_test.go} (100%)
delete mode 100644 internal/fixtures/recursive_generation/subpkg1/Foo_mock.go
delete mode 100644 internal/fixtures/recursive_generation/subpkg2/Foo_mock.go
delete mode 100644 internal/fixtures/recursive_generation/subpkg_with_only_autogenerated_files/Foo_mock.go
delete mode 100644 internal/fixtures/type_alias/mock_Interface1_test.go
delete mode 100644 internal/fixtures/type_alias/mock_Interface2_test.go
create mode 100644 internal/fixtures/type_alias/mocks_test.go
rename internal/fixtures/{test => }/variadic_return_func_test.go (74%)
delete mode 100644 mocks/github.com/vektra/mockery/v3/internal/fixtures/buildtag/comment/IfaceWithCustomBuildTagInComment_mock.go
diff --git a/.mockery.yml b/.mockery.yml
index a5a28830..c3cde5e7 100644
--- a/.mockery.yml
+++ b/.mockery.yml
@@ -1,34 +1,20 @@
template: "mockery"
-mockname: "{{.InterfaceName}}"
-filename: "{{.MockName}}_mock.go"
-pkgname: mocks
tags: "custom2"
formatter: "noop"
-_anchors: &inpackage_config
- all: True
- dir: "{{.InterfaceDir}}"
- mockname: "Mock{{.InterfaceName}}"
- pkgname: "{{.SrcPackageName}}_test"
- filename: "mock_{{.InterfaceName | snakecase }}_test.go"
+all: True
+dir: "{{.InterfaceDir}}"
+mockname: "Mock{{.InterfaceName}}"
+pkgname: "{{.SrcPackageName}}"
+filename: "mocks_test.go"
packages:
github.com/vektra/mockery/v3/internal/fixtures/buildtag/comment:
- config:
- mock-build-tags: "custom3 && (!windows || !darwin || !freebsd)"
- interfaces:
- IfaceWithCustomBuildTagInComment:
github.com/vektra/mockery/v3/pkg:
+ config:
+ all: False
interfaces:
TypesPackage:
github.com/vektra/mockery/v3/internal/fixtures:
- config:
- all: True
- dir: "{{.InterfaceDir}}"
- filename: "mocks.go"
- pkgname: "test"
- mockname: "Mock{{.InterfaceName}}"
interfaces:
- Requester:
- RequesterArgSameAsNamedImport:
RequesterVariadic:
configs:
- mockname: MockRequesterVariadicOneArgument
@@ -45,52 +31,15 @@ packages:
- mockname: MockExpecter
template-data:
unroll-variadic: True
- RequesterReturnElided:
VariadicNoReturnInterface:
config:
template-data:
unroll-variadic: False
github.com/vektra/mockery/v3/internal/fixtures/recursive_generation:
- config:
- recursive: True
- all: True
- dir: "{{.InterfaceDir}}"
- filename: "{{.InterfaceName}}_mock.go"
- mockname: "Mock{{.InterfaceName}}"
- pkgname: "{{.SrcPackageName}}"
github.com/vektra/mockery/v3/internal/fixtures/empty_return:
- config:
- all: True
- dir: "{{.InterfaceDir}}"
- mockname: "{{.InterfaceName}}Mock"
- pkgname: "{{.SrcPackageName}}"
- filename: "mock_{{.InterfaceName}}_test.go"
github.com/vektra/mockery/v3/internal/fixtures/method_args/same_name_arg_and_type:
- config:
- all: True
- dir: "{{.InterfaceDir}}"
- mockname: "{{.InterfaceName}}Mock"
- pkgname: "{{.SrcPackageName}}"
- filename: "mock_{{.InterfaceName}}_test.go"
github.com/vektra/mockery/v3/internal/fixtures/iface_typed_param:
- config: *inpackage_config
github.com/vektra/mockery/v3/internal/fixtures/example_project:
- config: *inpackage_config
github.com/vektra/mockery/v3/internal/fixtures/index_list_expr:
- config: *inpackage_config
github.com/vektra/mockery/v3/internal/fixtures/iface_new_type:
- config: *inpackage_config
- github.com/vektra/mockery/v3/internal/fixtures/issue845:
- config:
- <<: *inpackage_config
- filename: "mock_{{.MockName}}_test.go"
- interfaces:
- Interface:
- configs:
- - mockname: WithFix
github.com/vektra/mockery/v3/internal/fixtures/type_alias:
- config:
- all: True
- dir: "{{.InterfaceDir}}"
- filename: "mock_{{.MockName}}_test.go"
- pkgname: "{{.SrcPackageName}}_test"
diff --git a/Taskfile.yml b/Taskfile.yml
index 5b8b4c05..42d11913 100644
--- a/Taskfile.yml
+++ b/Taskfile.yml
@@ -21,7 +21,7 @@ tasks:
mocks.remove:
desc: remove all mock files
cmds:
- - find . -name '*_mock.go' -o -name 'mock_*_test.go' -o -name 'mocks.go' -o -name "mocks_moq.go" | xargs -r rm
+ - find . -name '*_mock.go' -o -name 'mock_*_test.go' -o -name 'mocks.go' -o -name "mocks_moq.go" -o -name 'mocks_test.go' -o -name 'mocks_moq_test.go' | xargs -r rm
- rm -rf mocks/
mocks.generate.mockery:
diff --git a/docs/templates.md b/docs/templates.md
index 9db9be10..9858f208 100644
--- a/docs/templates.md
+++ b/docs/templates.md
@@ -302,6 +302,7 @@ Moq-style mocks are far simpler, and probably more intuitive, than mockery-style
|-----|------|-------------|
| `skip-ensure` | `#!yaml bool` | Suppress mock implementation check, avoid import cycle if mocks generated outside of the tested package. |
| `stub-impl` | `#!yaml bool` | Return zero values when no mock implementation is provided, do not panic. |
+| `with-resets` | `#!yaml bool` | Generates methods that allow resetting calls made to the mocks. |
### `#!yaml template: "file://`
@@ -309,72 +310,25 @@ You may also provide mockery a path to your own file using the `file://` protoco
## Data Provided To Templates
-!!! warning "Construction"
-
- This section is under construction.
-
-mockery configuration makes use of the Go templating system.
-
-### Variables
-
-!!! note
- Templated variables are only available when using the `packages` config feature.
-
-Variables that are marked as being templated are capable of using mockery-provided template parameters.
-
-| name | description |
-|-------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
-| ConfigDir | The directory path of the config file used. This is used to allow generation of mocks in a directory relative to the `.mockery.yaml` file, e.g. external interfaces. |
-| InterfaceDir | The directory path of the original interface being mocked. This can be used as
`#!yaml dir: "{{.InterfaceDir}}"` to place your mocks adjacent to the original interface. This should not be used for external interfaces. |
-| InterfaceDirRelative | The directory path of the original interface being mocked, relative to the current working directory. If the path cannot be made relative to the current working directory, this variable will be set equal to `PackagePath` |
-| InterfaceFile | The file path of the original interface being mocked. **NOTE:** This option will only write one mock implementation to the output file. If multiple mocks are defined in your original file, only one mock will be written to the output. |
-| InterfaceName | The name of the original interface being mocked |
-| InterfaceNameCamel | Converts a string `interface_name` to `InterfaceName`.
DEPRECATED: use `{{ .InterfaceName | camelcase }}` instead |
-| InterfaceNameLowerCamel | Converts `InterfaceName` to `interfaceName` .
DEPRECATED: use `{{ .InterfaceName | camelcase | firstLower }}` instead |
-| InterfaceNameSnake | Converts `InterfaceName` to `interface_name` .
DEPRECATED: use `{{ .InterfaceName | snakecase }}` instead |
-| InterfaceNameLower | Converts `InterfaceName` to `interfacename` .
DEPRECATED: use `{{ .InterfaceName | lower }}` instead |
-| Mock | A string that is `Mock` if the interface is exported, or `mock` if it is not exported. Useful when setting the name of your mock to something like:
`#!yaml mockname: "{{.Mock}}{{.InterfaceName}}"`
This way, the mock name will retain the exported-ness of the original interface. |
-| MockName | The name of the mock that will be generated. Note that this is simply the `mockname` configuration variable |
-| PackageName | The name of the package from the original interface |
-| PackagePath | The fully qualified package path of the original interface |
-
-### Functions
-
-!!! note
- Templated functions are only available when using the `packages` config feature.
-
-Template functions allow you to inspect and manipulate template variables.
-
-All template functions are calling native Go functions under the hood, so signatures and return values matches the Go functions you are probably already familiar with.
-
-To learn more about the templating syntax, please [see the Go `text/template` documentation](https://pkg.go.dev/text/template)
-
-* [`contains` string substr](https://pkg.go.dev/strings#Contains)
-* [`hasPrefix` string prefix](https://pkg.go.dev/strings#HasPrefix)
-* [`hasSuffix` string suffix](https://pkg.go.dev/strings#HasSuffix)
-* [`join` elems sep](https://pkg.go.dev/strings#Join)
-* [`replace` string old new n](https://pkg.go.dev/strings#Replace)
-* [`replaceAll` string old new](https://pkg.go.dev/strings#ReplaceAll)
-* [`split` string sep](https://pkg.go.dev/strings#Split)
-* [`splitAfter` string sep](https://pkg.go.dev/strings#SplitAfter)
-* [`splitAfterN` string sep n](https://pkg.go.dev/strings#SplitAfterN)
-* [`trim` string cutset](https://pkg.go.dev/strings#Trim)
-* [`trimLeft` string cutset](https://pkg.go.dev/strings#TrimLeft)
-* [`trimPrefix` string prefix](https://pkg.go.dev/strings#TrimPrefix)
-* [`trimRight` string cutset](https://pkg.go.dev/strings#TrimRight)
-* [`trimSpace` string](https://pkg.go.dev/strings#TrimSpace)
-* [`trimSuffix` string suffix](https://pkg.go.dev/strings#TrimSuffix)
-* [`lower` string](https://pkg.go.dev/strings#ToLower)
-* [`upper` string](https://pkg.go.dev/strings#ToUpper)
-* [`camelcase` string](https://pkg.go.dev/github.com/huandu/xstrings#ToCamelCase)
-* [`snakecase` string](https://pkg.go.dev/github.com/huandu/xstrings#ToSnakeCase)
-* [`kebabcase` string](https://pkg.go.dev/github.com/huandu/xstrings#ToKebabCase)
-* [`firstLower` string](https://pkg.go.dev/github.com/huandu/xstrings#FirstRuneToLower)
-* [`firstUpper` string](https://pkg.go.dev/github.com/huandu/xstrings#FirstRuneToUpper)
-* [`matchString` pattern](https://pkg.go.dev/regexp#MatchString)
-* [`quoteMeta` string](https://pkg.go.dev/regexp#QuoteMeta)
-* [`base` string](https://pkg.go.dev/path/filepath#Base)
-* [`clean` string](https://pkg.go.dev/path/filepath#Clean)
-* [`dir` string](https://pkg.go.dev/path/filepath#Dir)
-* [`expandEnv` string](https://pkg.go.dev/os#ExpandEnv)
-* [`getenv` string](https://pkg.go.dev/os#Getenv)
+Mockery has two separate template instances: one for the `.mockery.yml` file, and one for the mock templates. Each instance has a different set of variables and functions available to it. All functions are [pipeline-compatible](https://pkg.go.dev/text/template#hdr-Pipelines).
+
+### `.mockery.yml`
+
+#### Functions
+
+As seen in the [configuration](configuration.md) section, mockery configuration has template variables and methods available to it. The functions available for use are defined in the [`StringManipulationFuncs`](https://pkg.go.dev/github.com/vektra/mockery/v3/template#pkg-variables).
+
+#### Variables
+
+The variables available are defined in the [`template.ConfigData`](https://pkg.go.dev/github.com/vektra/mockery/v3/template#ConfigData) struct.
+
+
+### Template Files
+
+#### Functions
+
+Template files have both [`StringManipulationFuncs`](https://pkg.go.dev/github.com/vektra/mockery/v3/template#pkg-variables) and [`TemplateMockFuncs`](https://pkg.go.dev/github.com/vektra/mockery/v3@v3.0.0-alpha.10/template#pkg-variables) available as functions.
+
+#### Variables
+
+The template is supplied with the [`template.Data`](https://pkg.go.dev/github.com/vektra/mockery/v3/template#Data) struct. Some attributes return types such as [`template.MockData`](https://pkg.go.dev/github.com/vektra/mockery/v3@v3.0.0-alpha.10/template#MockData) and [`registry.Package`](https://pkg.go.dev/github.com/vektra/mockery/v3/registry#Package) which themselves contain methods that may also be called.
diff --git a/internal/config.go b/internal/config.go
index 44979c36..0aab57a7 100644
--- a/internal/config.go
+++ b/internal/config.go
@@ -797,17 +797,7 @@ func (c *Config) ParseTemplates(ctx context.Context, iface *Interface, srcPkg *p
interfaceDirRelative = interfaceDirRelativePath.String()
}
// data is the struct sent to the template parser
- data := struct {
- ConfigDir string
- InterfaceDir string
- InterfaceDirRelative string
- InterfaceFile string
- InterfaceName string
- Mock string
- MockName string
- SrcPackageName string
- SrcPackagePath string
- }{
+ data := mockeryTemplate.ConfigData{
ConfigDir: filepath.Dir(c.Config),
InterfaceDir: interfaceDir,
InterfaceDirRelative: interfaceDirRelative,
diff --git a/internal/fixtures/buildtag/comment/mocks_test.go b/internal/fixtures/buildtag/comment/mocks_test.go
new file mode 100644
index 00000000..36f7f4ee
--- /dev/null
+++ b/internal/fixtures/buildtag/comment/mocks_test.go
@@ -0,0 +1,233 @@
+
+// Code generated by mockery; DO NOT EDIT.
+// github.com/vektra/mockery
+
+package comment
+
+import (
+ mock "github.com/stretchr/testify/mock"
+)
+
+
+// NewMockIfaceWithCustomBuildTagInComment creates a new instance of MockIfaceWithCustomBuildTagInComment. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
+// The first argument is typically a *testing.T value.
+func NewMockIfaceWithCustomBuildTagInComment (t interface {
+ mock.TestingT
+ Cleanup(func())
+}) *MockIfaceWithCustomBuildTagInComment {
+ mock := &MockIfaceWithCustomBuildTagInComment{}
+ mock.Mock.Test(t)
+
+ t.Cleanup(func() { mock.AssertExpectations(t) })
+
+ return mock
+}
+
+
+// MockIfaceWithCustomBuildTagInComment is an autogenerated mock type for the IfaceWithCustomBuildTagInComment type
+type MockIfaceWithCustomBuildTagInComment struct {
+ mock.Mock
+}
+
+type MockIfaceWithCustomBuildTagInComment_Expecter struct {
+ mock *mock.Mock
+}
+
+func (_m *MockIfaceWithCustomBuildTagInComment) EXPECT() *MockIfaceWithCustomBuildTagInComment_Expecter {
+ return &MockIfaceWithCustomBuildTagInComment_Expecter{mock: &_m.Mock}
+}
+
+
+
+// Custom2 provides a mock function for the type MockIfaceWithCustomBuildTagInComment
+func (_mock *MockIfaceWithCustomBuildTagInComment) Custom2() { _mock.Called()
+ return
+}
+
+
+
+// MockIfaceWithCustomBuildTagInComment_Custom2_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Custom2'
+type MockIfaceWithCustomBuildTagInComment_Custom2_Call struct {
+ *mock.Call
+}
+
+
+
+// Custom2 is a helper method to define mock.On call
+func (_e *MockIfaceWithCustomBuildTagInComment_Expecter) Custom2() *MockIfaceWithCustomBuildTagInComment_Custom2_Call {
+ return &MockIfaceWithCustomBuildTagInComment_Custom2_Call{Call: _e.mock.On("Custom2", )}
+}
+
+func (_c *MockIfaceWithCustomBuildTagInComment_Custom2_Call) Run(run func()) *MockIfaceWithCustomBuildTagInComment_Custom2_Call {
+ _c.Call.Run(func(args mock.Arguments) {
+ run()
+ })
+ return _c
+}
+
+func (_c *MockIfaceWithCustomBuildTagInComment_Custom2_Call) Return() *MockIfaceWithCustomBuildTagInComment_Custom2_Call {
+ _c.Call.Return()
+ return _c
+}
+
+func (_c *MockIfaceWithCustomBuildTagInComment_Custom2_Call) RunAndReturn(run func()) *MockIfaceWithCustomBuildTagInComment_Custom2_Call {
+ _c.Run(run)
+ return _c
+}
+
+
+// Sprintf provides a mock function for the type MockIfaceWithCustomBuildTagInComment
+func (_mock *MockIfaceWithCustomBuildTagInComment) Sprintf(format string, a ...interface{}) string {
+ var tmpRet mock.Arguments
+ if len(a) > 0 {tmpRet = _mock.Called(format, a)
+ } else {tmpRet = _mock.Called(format)
+ }
+ ret := tmpRet
+
+ if len(ret) == 0 {
+ panic("no return value specified for Sprintf")
+ }
+
+
+ var r0 string
+ if returnFunc, ok := ret.Get(0).(func(string, ...interface{}) string); ok {
+ r0 = returnFunc(format, a...)
+ } else {
+ r0 = ret.Get(0).(string)
+ }
+ return r0
+}
+
+
+
+// MockIfaceWithCustomBuildTagInComment_Sprintf_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Sprintf'
+type MockIfaceWithCustomBuildTagInComment_Sprintf_Call struct {
+ *mock.Call
+}
+
+
+
+// Sprintf is a helper method to define mock.On call
+// - format
+// - a
+func (_e *MockIfaceWithCustomBuildTagInComment_Expecter) Sprintf(format interface{}, a ...interface{}, ) *MockIfaceWithCustomBuildTagInComment_Sprintf_Call {
+ return &MockIfaceWithCustomBuildTagInComment_Sprintf_Call{Call: _e.mock.On("Sprintf",
+ append([]interface{}{ format, }, a... )... )}
+}
+
+func (_c *MockIfaceWithCustomBuildTagInComment_Sprintf_Call) Run(run func(format string, a ...interface{})) *MockIfaceWithCustomBuildTagInComment_Sprintf_Call {
+ _c.Call.Run(func(args mock.Arguments) {
+ variadicArgs := make([]interface{}, len(args) - 1)
+ for i, a := range args[1:] {
+ if a != nil {
+ variadicArgs[i] = a.(interface{})
+ }
+ }
+ run(args[0].(string),variadicArgs...)
+ })
+ return _c
+}
+
+func (_c *MockIfaceWithCustomBuildTagInComment_Sprintf_Call) Return(s string) *MockIfaceWithCustomBuildTagInComment_Sprintf_Call {
+ _c.Call.Return(s)
+ return _c
+}
+
+func (_c *MockIfaceWithCustomBuildTagInComment_Sprintf_Call) RunAndReturn(run func(format string, a ...interface{})string) *MockIfaceWithCustomBuildTagInComment_Sprintf_Call {
+ _c.Call.Return(run)
+ return _c
+}
+
+// NewMockIfaceWithBuildTagInComment creates a new instance of MockIfaceWithBuildTagInComment. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
+// The first argument is typically a *testing.T value.
+func NewMockIfaceWithBuildTagInComment (t interface {
+ mock.TestingT
+ Cleanup(func())
+}) *MockIfaceWithBuildTagInComment {
+ mock := &MockIfaceWithBuildTagInComment{}
+ mock.Mock.Test(t)
+
+ t.Cleanup(func() { mock.AssertExpectations(t) })
+
+ return mock
+}
+
+
+// MockIfaceWithBuildTagInComment is an autogenerated mock type for the IfaceWithBuildTagInComment type
+type MockIfaceWithBuildTagInComment struct {
+ mock.Mock
+}
+
+type MockIfaceWithBuildTagInComment_Expecter struct {
+ mock *mock.Mock
+}
+
+func (_m *MockIfaceWithBuildTagInComment) EXPECT() *MockIfaceWithBuildTagInComment_Expecter {
+ return &MockIfaceWithBuildTagInComment_Expecter{mock: &_m.Mock}
+}
+
+
+
+// Sprintf provides a mock function for the type MockIfaceWithBuildTagInComment
+func (_mock *MockIfaceWithBuildTagInComment) Sprintf(format string, a ...interface{}) string {
+ var tmpRet mock.Arguments
+ if len(a) > 0 {tmpRet = _mock.Called(format, a)
+ } else {tmpRet = _mock.Called(format)
+ }
+ ret := tmpRet
+
+ if len(ret) == 0 {
+ panic("no return value specified for Sprintf")
+ }
+
+
+ var r0 string
+ if returnFunc, ok := ret.Get(0).(func(string, ...interface{}) string); ok {
+ r0 = returnFunc(format, a...)
+ } else {
+ r0 = ret.Get(0).(string)
+ }
+ return r0
+}
+
+
+
+// MockIfaceWithBuildTagInComment_Sprintf_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Sprintf'
+type MockIfaceWithBuildTagInComment_Sprintf_Call struct {
+ *mock.Call
+}
+
+
+
+// Sprintf is a helper method to define mock.On call
+// - format
+// - a
+func (_e *MockIfaceWithBuildTagInComment_Expecter) Sprintf(format interface{}, a ...interface{}, ) *MockIfaceWithBuildTagInComment_Sprintf_Call {
+ return &MockIfaceWithBuildTagInComment_Sprintf_Call{Call: _e.mock.On("Sprintf",
+ append([]interface{}{ format, }, a... )... )}
+}
+
+func (_c *MockIfaceWithBuildTagInComment_Sprintf_Call) Run(run func(format string, a ...interface{})) *MockIfaceWithBuildTagInComment_Sprintf_Call {
+ _c.Call.Run(func(args mock.Arguments) {
+ variadicArgs := make([]interface{}, len(args) - 1)
+ for i, a := range args[1:] {
+ if a != nil {
+ variadicArgs[i] = a.(interface{})
+ }
+ }
+ run(args[0].(string),variadicArgs...)
+ })
+ return _c
+}
+
+func (_c *MockIfaceWithBuildTagInComment_Sprintf_Call) Return(s string) *MockIfaceWithBuildTagInComment_Sprintf_Call {
+ _c.Call.Return(s)
+ return _c
+}
+
+func (_c *MockIfaceWithBuildTagInComment_Sprintf_Call) RunAndReturn(run func(format string, a ...interface{})string) *MockIfaceWithBuildTagInComment_Sprintf_Call {
+ _c.Call.Return(run)
+ return _c
+}
+
+
diff --git a/internal/fixtures/empty_return/interface.go b/internal/fixtures/empty_return/interface.go
index 8ece725a..2348ee18 100644
--- a/internal/fixtures/empty_return/interface.go
+++ b/internal/fixtures/empty_return/interface.go
@@ -1,4 +1,4 @@
-package test
+package empty_return
type EmptyReturn interface {
NoArgs()
diff --git a/internal/fixtures/empty_return/interface_test.go b/internal/fixtures/empty_return/interface_test.go
index 6039d146..fabbb417 100644
--- a/internal/fixtures/empty_return/interface_test.go
+++ b/internal/fixtures/empty_return/interface_test.go
@@ -1,4 +1,4 @@
-package test
+package empty_return
import (
"testing"
@@ -7,7 +7,7 @@ import (
)
func Test(t *testing.T) {
- m := NewEmptyReturnMock(t)
+ m := NewMockEmptyReturn(t)
var target EmptyReturn = m
t.Run("NoArgs", func(t *testing.T) {
diff --git a/internal/fixtures/empty_return/mock_EmptyReturn_test.go b/internal/fixtures/empty_return/mock_EmptyReturn_test.go
deleted file mode 100644
index 35449560..00000000
--- a/internal/fixtures/empty_return/mock_EmptyReturn_test.go
+++ /dev/null
@@ -1,117 +0,0 @@
-
-// Code generated by mockery; DO NOT EDIT.
-// github.com/vektra/mockery
-
-package test
-
-import (
- mock "github.com/stretchr/testify/mock"
-)
-
-
-// NewEmptyReturnMock creates a new instance of EmptyReturnMock. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
-// The first argument is typically a *testing.T value.
-func NewEmptyReturnMock (t interface {
- mock.TestingT
- Cleanup(func())
-}) *EmptyReturnMock {
- mock := &EmptyReturnMock{}
- mock.Mock.Test(t)
-
- t.Cleanup(func() { mock.AssertExpectations(t) })
-
- return mock
-}
-
-
-// EmptyReturnMock is an autogenerated mock type for the EmptyReturn type
-type EmptyReturnMock struct {
- mock.Mock
-}
-
-type EmptyReturnMock_Expecter struct {
- mock *mock.Mock
-}
-
-func (_m *EmptyReturnMock) EXPECT() *EmptyReturnMock_Expecter {
- return &EmptyReturnMock_Expecter{mock: &_m.Mock}
-}
-
-
-
-// NoArgs provides a mock function for the type EmptyReturnMock
-func (_mock *EmptyReturnMock) NoArgs() { _mock.Called()
- return
-}
-
-
-
-// EmptyReturnMock_NoArgs_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'NoArgs'
-type EmptyReturnMock_NoArgs_Call struct {
- *mock.Call
-}
-
-
-
-// NoArgs is a helper method to define mock.On call
-func (_e *EmptyReturnMock_Expecter) NoArgs() *EmptyReturnMock_NoArgs_Call {
- return &EmptyReturnMock_NoArgs_Call{Call: _e.mock.On("NoArgs", )}
-}
-
-func (_c *EmptyReturnMock_NoArgs_Call) Run(run func()) *EmptyReturnMock_NoArgs_Call {
- _c.Call.Run(func(args mock.Arguments) {
- run()
- })
- return _c
-}
-
-func (_c *EmptyReturnMock_NoArgs_Call) Return() *EmptyReturnMock_NoArgs_Call {
- _c.Call.Return()
- return _c
-}
-
-func (_c *EmptyReturnMock_NoArgs_Call) RunAndReturn(run func()) *EmptyReturnMock_NoArgs_Call {
- _c.Run(run)
- return _c
-}
-
-
-// WithArgs provides a mock function for the type EmptyReturnMock
-func (_mock *EmptyReturnMock) WithArgs(a int, b string) { _mock.Called(a, b)
- return
-}
-
-
-
-// EmptyReturnMock_WithArgs_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WithArgs'
-type EmptyReturnMock_WithArgs_Call struct {
- *mock.Call
-}
-
-
-
-// WithArgs is a helper method to define mock.On call
-// - a
-// - b
-func (_e *EmptyReturnMock_Expecter) WithArgs(a interface{}, b interface{}, ) *EmptyReturnMock_WithArgs_Call {
- return &EmptyReturnMock_WithArgs_Call{Call: _e.mock.On("WithArgs",a,b, )}
-}
-
-func (_c *EmptyReturnMock_WithArgs_Call) Run(run func(a int, b string)) *EmptyReturnMock_WithArgs_Call {
- _c.Call.Run(func(args mock.Arguments) {
- run(args[0].(int),args[1].(string),)
- })
- return _c
-}
-
-func (_c *EmptyReturnMock_WithArgs_Call) Return() *EmptyReturnMock_WithArgs_Call {
- _c.Call.Return()
- return _c
-}
-
-func (_c *EmptyReturnMock_WithArgs_Call) RunAndReturn(run func(a int, b string)) *EmptyReturnMock_WithArgs_Call {
- _c.Run(run)
- return _c
-}
-
-
diff --git a/internal/fixtures/empty_return/mocks_test.go b/internal/fixtures/empty_return/mocks_test.go
new file mode 100644
index 00000000..ace9b11e
--- /dev/null
+++ b/internal/fixtures/empty_return/mocks_test.go
@@ -0,0 +1,117 @@
+
+// Code generated by mockery; DO NOT EDIT.
+// github.com/vektra/mockery
+
+package empty_return
+
+import (
+ mock "github.com/stretchr/testify/mock"
+)
+
+
+// NewMockEmptyReturn creates a new instance of MockEmptyReturn. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
+// The first argument is typically a *testing.T value.
+func NewMockEmptyReturn (t interface {
+ mock.TestingT
+ Cleanup(func())
+}) *MockEmptyReturn {
+ mock := &MockEmptyReturn{}
+ mock.Mock.Test(t)
+
+ t.Cleanup(func() { mock.AssertExpectations(t) })
+
+ return mock
+}
+
+
+// MockEmptyReturn is an autogenerated mock type for the EmptyReturn type
+type MockEmptyReturn struct {
+ mock.Mock
+}
+
+type MockEmptyReturn_Expecter struct {
+ mock *mock.Mock
+}
+
+func (_m *MockEmptyReturn) EXPECT() *MockEmptyReturn_Expecter {
+ return &MockEmptyReturn_Expecter{mock: &_m.Mock}
+}
+
+
+
+// NoArgs provides a mock function for the type MockEmptyReturn
+func (_mock *MockEmptyReturn) NoArgs() { _mock.Called()
+ return
+}
+
+
+
+// MockEmptyReturn_NoArgs_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'NoArgs'
+type MockEmptyReturn_NoArgs_Call struct {
+ *mock.Call
+}
+
+
+
+// NoArgs is a helper method to define mock.On call
+func (_e *MockEmptyReturn_Expecter) NoArgs() *MockEmptyReturn_NoArgs_Call {
+ return &MockEmptyReturn_NoArgs_Call{Call: _e.mock.On("NoArgs", )}
+}
+
+func (_c *MockEmptyReturn_NoArgs_Call) Run(run func()) *MockEmptyReturn_NoArgs_Call {
+ _c.Call.Run(func(args mock.Arguments) {
+ run()
+ })
+ return _c
+}
+
+func (_c *MockEmptyReturn_NoArgs_Call) Return() *MockEmptyReturn_NoArgs_Call {
+ _c.Call.Return()
+ return _c
+}
+
+func (_c *MockEmptyReturn_NoArgs_Call) RunAndReturn(run func()) *MockEmptyReturn_NoArgs_Call {
+ _c.Run(run)
+ return _c
+}
+
+
+// WithArgs provides a mock function for the type MockEmptyReturn
+func (_mock *MockEmptyReturn) WithArgs(a int, b string) { _mock.Called(a, b)
+ return
+}
+
+
+
+// MockEmptyReturn_WithArgs_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WithArgs'
+type MockEmptyReturn_WithArgs_Call struct {
+ *mock.Call
+}
+
+
+
+// WithArgs is a helper method to define mock.On call
+// - a
+// - b
+func (_e *MockEmptyReturn_Expecter) WithArgs(a interface{}, b interface{}, ) *MockEmptyReturn_WithArgs_Call {
+ return &MockEmptyReturn_WithArgs_Call{Call: _e.mock.On("WithArgs",a,b, )}
+}
+
+func (_c *MockEmptyReturn_WithArgs_Call) Run(run func(a int, b string)) *MockEmptyReturn_WithArgs_Call {
+ _c.Call.Run(func(args mock.Arguments) {
+ run(args[0].(int),args[1].(string),)
+ })
+ return _c
+}
+
+func (_c *MockEmptyReturn_WithArgs_Call) Return() *MockEmptyReturn_WithArgs_Call {
+ _c.Call.Return()
+ return _c
+}
+
+func (_c *MockEmptyReturn_WithArgs_Call) RunAndReturn(run func(a int, b string)) *MockEmptyReturn_WithArgs_Call {
+ _c.Run(run)
+ return _c
+}
+
+
diff --git a/internal/fixtures/example_project/mock_stringer_test.go b/internal/fixtures/example_project/mock_stringer_test.go
deleted file mode 100644
index 1fc88fdf..00000000
--- a/internal/fixtures/example_project/mock_stringer_test.go
+++ /dev/null
@@ -1,91 +0,0 @@
-
-// Code generated by mockery; DO NOT EDIT.
-// github.com/vektra/mockery
-
-package example_project_test
-
-import (
- mock "github.com/stretchr/testify/mock"
-)
-
-
-// NewMockStringer creates a new instance of MockStringer. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
-// The first argument is typically a *testing.T value.
-func NewMockStringer (t interface {
- mock.TestingT
- Cleanup(func())
-}) *MockStringer {
- mock := &MockStringer{}
- mock.Mock.Test(t)
-
- t.Cleanup(func() { mock.AssertExpectations(t) })
-
- return mock
-}
-
-
-// MockStringer is an autogenerated mock type for the Stringer type
-type MockStringer struct {
- mock.Mock
-}
-
-type MockStringer_Expecter struct {
- mock *mock.Mock
-}
-
-func (_m *MockStringer) EXPECT() *MockStringer_Expecter {
- return &MockStringer_Expecter{mock: &_m.Mock}
-}
-
-
-
-// String provides a mock function for the type MockStringer
-func (_mock *MockStringer) String() string {
- ret := _mock.Called()
-
- if len(ret) == 0 {
- panic("no return value specified for String")
- }
-
-
- var r0 string
- if returnFunc, ok := ret.Get(0).(func() string); ok {
- r0 = returnFunc()
- } else {
- r0 = ret.Get(0).(string)
- }
- return r0
-}
-
-
-
-// MockStringer_String_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'String'
-type MockStringer_String_Call struct {
- *mock.Call
-}
-
-
-
-// String is a helper method to define mock.On call
-func (_e *MockStringer_Expecter) String() *MockStringer_String_Call {
- return &MockStringer_String_Call{Call: _e.mock.On("String", )}
-}
-
-func (_c *MockStringer_String_Call) Run(run func()) *MockStringer_String_Call {
- _c.Call.Run(func(args mock.Arguments) {
- run()
- })
- return _c
-}
-
-func (_c *MockStringer_String_Call) Return(s string) *MockStringer_String_Call {
- _c.Call.Return(s)
- return _c
-}
-
-func (_c *MockStringer_String_Call) RunAndReturn(run func()string) *MockStringer_String_Call {
- _c.Call.Return(run)
- return _c
-}
-
-
diff --git a/internal/fixtures/example_project/mock_root_test.go b/internal/fixtures/example_project/mocks_test.go
similarity index 63%
rename from internal/fixtures/example_project/mock_root_test.go
rename to internal/fixtures/example_project/mocks_test.go
index be8799ab..92ecff91 100644
--- a/internal/fixtures/example_project/mock_root_test.go
+++ b/internal/fixtures/example_project/mocks_test.go
@@ -2,7 +2,7 @@
// Code generated by mockery; DO NOT EDIT.
// github.com/vektra/mockery
-package example_project_test
+package example_project
import (
"github.com/vektra/mockery/v3/internal/fixtures/example_project/foo"
@@ -138,4 +138,83 @@ func (_c *MockRoot_TakesBaz_Call) RunAndReturn(run func(baz *foo.Baz)) *MockRoot
return _c
}
+// NewMockStringer creates a new instance of MockStringer. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
+// The first argument is typically a *testing.T value.
+func NewMockStringer (t interface {
+ mock.TestingT
+ Cleanup(func())
+}) *MockStringer {
+ mock := &MockStringer{}
+ mock.Mock.Test(t)
+
+ t.Cleanup(func() { mock.AssertExpectations(t) })
+
+ return mock
+}
+
+
+// MockStringer is an autogenerated mock type for the Stringer type
+type MockStringer struct {
+ mock.Mock
+}
+
+type MockStringer_Expecter struct {
+ mock *mock.Mock
+}
+
+func (_m *MockStringer) EXPECT() *MockStringer_Expecter {
+ return &MockStringer_Expecter{mock: &_m.Mock}
+}
+
+
+
+// String provides a mock function for the type MockStringer
+func (_mock *MockStringer) String() string {
+ ret := _mock.Called()
+
+ if len(ret) == 0 {
+ panic("no return value specified for String")
+ }
+
+
+ var r0 string
+ if returnFunc, ok := ret.Get(0).(func() string); ok {
+ r0 = returnFunc()
+ } else {
+ r0 = ret.Get(0).(string)
+ }
+ return r0
+}
+
+
+
+// MockStringer_String_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'String'
+type MockStringer_String_Call struct {
+ *mock.Call
+}
+
+
+
+// String is a helper method to define mock.On call
+func (_e *MockStringer_Expecter) String() *MockStringer_String_Call {
+ return &MockStringer_String_Call{Call: _e.mock.On("String", )}
+}
+
+func (_c *MockStringer_String_Call) Run(run func()) *MockStringer_String_Call {
+ _c.Call.Run(func(args mock.Arguments) {
+ run()
+ })
+ return _c
+}
+
+func (_c *MockStringer_String_Call) Return(s string) *MockStringer_String_Call {
+ _c.Call.Return(s)
+ return _c
+}
+
+func (_c *MockStringer_String_Call) RunAndReturn(run func()string) *MockStringer_String_Call {
+ _c.Call.Return(run)
+ return _c
+}
+
diff --git a/internal/fixtures/example_project/replace_type/rt.go b/internal/fixtures/example_project/replace_type/rt.go
index c24a8ae3..b5863315 100644
--- a/internal/fixtures/example_project/replace_type/rt.go
+++ b/internal/fixtures/example_project/replace_type/rt.go
@@ -1,8 +1,8 @@
package replace_type
import (
- "github.com/vektra/mockery/v3/pkg/fixtures/example_project/replace_type/rti/rt1"
- "github.com/vektra/mockery/v3/pkg/fixtures/example_project/replace_type/rti/rt2"
+ "github.com/vektra/mockery/v3/internal/fixtures/example_project/replace_type/rti/rt1"
+ "github.com/vektra/mockery/v3/internal/fixtures/example_project/replace_type/rti/rt2"
)
type RType interface {
diff --git a/internal/fixtures/example_project/string_test.go b/internal/fixtures/example_project/string_test.go
index c06c9b25..5cef683e 100644
--- a/internal/fixtures/example_project/string_test.go
+++ b/internal/fixtures/example_project/string_test.go
@@ -1,13 +1,12 @@
-package example_project_test
+package example_project
import (
"testing"
"github.com/stretchr/testify/assert"
- "github.com/vektra/mockery/v3/internal/fixtures/example_project"
)
-func Foo(s example_project.Stringer) string {
+func Foo(s Stringer) string {
return s.String()
}
diff --git a/internal/fixtures/test/expecter_test.go b/internal/fixtures/expecter_test.go
similarity index 97%
rename from internal/fixtures/test/expecter_test.go
rename to internal/fixtures/expecter_test.go
index 0899a9dd..36162c32 100644
--- a/internal/fixtures/test/expecter_test.go
+++ b/internal/fixtures/expecter_test.go
@@ -8,7 +8,6 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
- mocks "github.com/vektra/mockery/v3/mocks/github.com/vektra/mockery/v3/internal/fixtures"
)
var (
@@ -19,7 +18,7 @@ var (
// Test that the generated code for ExpecterTest interface is usable
func TestExpecter(t *testing.T) {
- expMock := mocks.Expecter{}
+ expMock := NewMockExpecter(t)
t.Run("NoArg", func(t *testing.T) {
var runCalled bool
diff --git a/internal/fixtures/iface_new_type/iface_new_type_test.go b/internal/fixtures/iface_new_type/iface_new_type_test.go
index 8bb915d7..21c1fa4c 100644
--- a/internal/fixtures/iface_new_type/iface_new_type_test.go
+++ b/internal/fixtures/iface_new_type/iface_new_type_test.go
@@ -1,4 +1,4 @@
-package iface_new_type_test
+package iface_new_type
import (
"testing"
diff --git a/internal/fixtures/iface_new_type/mock_interface1_test.go b/internal/fixtures/iface_new_type/mocks_test.go
similarity index 98%
rename from internal/fixtures/iface_new_type/mock_interface1_test.go
rename to internal/fixtures/iface_new_type/mocks_test.go
index 71537dc8..402cd337 100644
--- a/internal/fixtures/iface_new_type/mock_interface1_test.go
+++ b/internal/fixtures/iface_new_type/mocks_test.go
@@ -2,7 +2,7 @@
// Code generated by mockery; DO NOT EDIT.
// github.com/vektra/mockery
-package iface_new_type_test
+package iface_new_type
import (
mock "github.com/stretchr/testify/mock"
diff --git a/internal/fixtures/iface_typed_param/main_test.go b/internal/fixtures/iface_typed_param/main_test.go
index 1dee4e1c..d3f1a050 100644
--- a/internal/fixtures/iface_typed_param/main_test.go
+++ b/internal/fixtures/iface_typed_param/main_test.go
@@ -1,4 +1,4 @@
-package iface_typed_param_test
+package iface_typed_param
import (
"bufio"
diff --git a/internal/fixtures/iface_typed_param/mock_getter_iface_typed_param_test.go b/internal/fixtures/iface_typed_param/mocks_test.go
similarity index 98%
rename from internal/fixtures/iface_typed_param/mock_getter_iface_typed_param_test.go
rename to internal/fixtures/iface_typed_param/mocks_test.go
index 518206e1..1a48c88c 100644
--- a/internal/fixtures/iface_typed_param/mock_getter_iface_typed_param_test.go
+++ b/internal/fixtures/iface_typed_param/mocks_test.go
@@ -2,7 +2,7 @@
// Code generated by mockery; DO NOT EDIT.
// github.com/vektra/mockery
-package iface_typed_param_test
+package iface_typed_param
import (
"io"
diff --git a/internal/fixtures/index_list_expr/index_list_expression_test.go b/internal/fixtures/index_list_expr/index_list_expression_test.go
index 7c87e785..62f029b1 100644
--- a/internal/fixtures/index_list_expr/index_list_expression_test.go
+++ b/internal/fixtures/index_list_expr/index_list_expression_test.go
@@ -1,4 +1,4 @@
-package index_list_expr_test
+package index_list_expr
import (
"testing"
diff --git a/internal/fixtures/index_list_expr/mock_index_list_expr_test.go b/internal/fixtures/index_list_expr/mock_index_list_expr_test.go
deleted file mode 100644
index d5e9f99e..00000000
--- a/internal/fixtures/index_list_expr/mock_index_list_expr_test.go
+++ /dev/null
@@ -1,93 +0,0 @@
-
-// Code generated by mockery; DO NOT EDIT.
-// github.com/vektra/mockery
-
-package index_list_expr_test
-
-import (
- mock "github.com/stretchr/testify/mock"
-)
-
-
-// NewMockIndexListExpr creates a new instance of MockIndexListExpr. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
-// The first argument is typically a *testing.T value.
-func NewMockIndexListExpr (t interface {
- mock.TestingT
- Cleanup(func())
-}) *MockIndexListExpr {
- mock := &MockIndexListExpr{}
- mock.Mock.Test(t)
-
- t.Cleanup(func() { mock.AssertExpectations(t) })
-
- return mock
-}
-
-
-// MockIndexListExpr is an autogenerated mock type for the IndexListExpr type
-type MockIndexListExpr struct {
- mock.Mock
-}
-
-type MockIndexListExpr_Expecter struct {
- mock *mock.Mock
-}
-
-func (_m *MockIndexListExpr) EXPECT() *MockIndexListExpr_Expecter {
- return &MockIndexListExpr_Expecter{mock: &_m.Mock}
-}
-
-
-
-// Func provides a mock function for the type MockIndexListExpr
-func (_mock *MockIndexListExpr) Func(arg1 *int, arg2 string) bool {
- ret := _mock.Called(arg1, arg2)
-
- if len(ret) == 0 {
- panic("no return value specified for Func")
- }
-
-
- var r0 bool
- if returnFunc, ok := ret.Get(0).(func(*int, string) bool); ok {
- r0 = returnFunc(arg1, arg2)
- } else {
- r0 = ret.Get(0).(bool)
- }
- return r0
-}
-
-
-
-// MockIndexListExpr_Func_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Func'
-type MockIndexListExpr_Func_Call struct {
- *mock.Call
-}
-
-
-
-// Func is a helper method to define mock.On call
-// - arg1
-// - arg2
-func (_e *MockIndexListExpr_Expecter) Func(arg1 interface{}, arg2 interface{}, ) *MockIndexListExpr_Func_Call {
- return &MockIndexListExpr_Func_Call{Call: _e.mock.On("Func",arg1,arg2, )}
-}
-
-func (_c *MockIndexListExpr_Func_Call) Run(run func(arg1 *int, arg2 string)) *MockIndexListExpr_Func_Call {
- _c.Call.Run(func(args mock.Arguments) {
- run(args[0].(*int),args[1].(string),)
- })
- return _c
-}
-
-func (_c *MockIndexListExpr_Func_Call) Return(b bool) *MockIndexListExpr_Func_Call {
- _c.Call.Return(b)
- return _c
-}
-
-func (_c *MockIndexListExpr_Func_Call) RunAndReturn(run func(arg1 *int, arg2 string)bool) *MockIndexListExpr_Func_Call {
- _c.Call.Return(run)
- return _c
-}
-
-
diff --git a/internal/fixtures/index_list_expr/mock_generic_multiple_types_test.go b/internal/fixtures/index_list_expr/mocks_test.go
similarity index 55%
rename from internal/fixtures/index_list_expr/mock_generic_multiple_types_test.go
rename to internal/fixtures/index_list_expr/mocks_test.go
index fb06b713..e7b524d1 100644
--- a/internal/fixtures/index_list_expr/mock_generic_multiple_types_test.go
+++ b/internal/fixtures/index_list_expr/mocks_test.go
@@ -2,7 +2,7 @@
// Code generated by mockery; DO NOT EDIT.
// github.com/vektra/mockery
-package index_list_expr_test
+package index_list_expr
import (
mock "github.com/stretchr/testify/mock"
@@ -92,4 +92,85 @@ func (_c *MockGenericMultipleTypes_Func_Call[T1, T2, T3]) RunAndReturn(run func(
return _c
}
+// NewMockIndexListExpr creates a new instance of MockIndexListExpr. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
+// The first argument is typically a *testing.T value.
+func NewMockIndexListExpr (t interface {
+ mock.TestingT
+ Cleanup(func())
+}) *MockIndexListExpr {
+ mock := &MockIndexListExpr{}
+ mock.Mock.Test(t)
+
+ t.Cleanup(func() { mock.AssertExpectations(t) })
+
+ return mock
+}
+
+
+// MockIndexListExpr is an autogenerated mock type for the IndexListExpr type
+type MockIndexListExpr struct {
+ mock.Mock
+}
+
+type MockIndexListExpr_Expecter struct {
+ mock *mock.Mock
+}
+
+func (_m *MockIndexListExpr) EXPECT() *MockIndexListExpr_Expecter {
+ return &MockIndexListExpr_Expecter{mock: &_m.Mock}
+}
+
+
+
+// Func provides a mock function for the type MockIndexListExpr
+func (_mock *MockIndexListExpr) Func(arg1 *int, arg2 string) bool {
+ ret := _mock.Called(arg1, arg2)
+
+ if len(ret) == 0 {
+ panic("no return value specified for Func")
+ }
+
+
+ var r0 bool
+ if returnFunc, ok := ret.Get(0).(func(*int, string) bool); ok {
+ r0 = returnFunc(arg1, arg2)
+ } else {
+ r0 = ret.Get(0).(bool)
+ }
+ return r0
+}
+
+
+
+// MockIndexListExpr_Func_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Func'
+type MockIndexListExpr_Func_Call struct {
+ *mock.Call
+}
+
+
+
+// Func is a helper method to define mock.On call
+// - arg1
+// - arg2
+func (_e *MockIndexListExpr_Expecter) Func(arg1 interface{}, arg2 interface{}, ) *MockIndexListExpr_Func_Call {
+ return &MockIndexListExpr_Func_Call{Call: _e.mock.On("Func",arg1,arg2, )}
+}
+
+func (_c *MockIndexListExpr_Func_Call) Run(run func(arg1 *int, arg2 string)) *MockIndexListExpr_Func_Call {
+ _c.Call.Run(func(args mock.Arguments) {
+ run(args[0].(*int),args[1].(string),)
+ })
+ return _c
+}
+
+func (_c *MockIndexListExpr_Func_Call) Return(b bool) *MockIndexListExpr_Func_Call {
+ _c.Call.Return(b)
+ return _c
+}
+
+func (_c *MockIndexListExpr_Func_Call) RunAndReturn(run func(arg1 *int, arg2 string)bool) *MockIndexListExpr_Func_Call {
+ _c.Call.Return(run)
+ return _c
+}
+
diff --git a/internal/fixtures/issue845/mock_WithFix_test.go b/internal/fixtures/issue845/mock_WithFix_test.go
deleted file mode 100644
index 79077aa2..00000000
--- a/internal/fixtures/issue845/mock_WithFix_test.go
+++ /dev/null
@@ -1,91 +0,0 @@
-
-// Code generated by mockery; DO NOT EDIT.
-// github.com/vektra/mockery
-
-package issue845_test
-
-import (
- mock "github.com/stretchr/testify/mock"
-)
-
-
-// NewWithFix creates a new instance of WithFix. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
-// The first argument is typically a *testing.T value.
-func NewWithFix (t interface {
- mock.TestingT
- Cleanup(func())
-}) *WithFix {
- mock := &WithFix{}
- mock.Mock.Test(t)
-
- t.Cleanup(func() { mock.AssertExpectations(t) })
-
- return mock
-}
-
-
-// WithFix is an autogenerated mock type for the Interface type
-type WithFix struct {
- mock.Mock
-}
-
-type WithFix_Expecter struct {
- mock *mock.Mock
-}
-
-func (_m *WithFix) EXPECT() *WithFix_Expecter {
- return &WithFix_Expecter{mock: &_m.Mock}
-}
-
-
-
-// Foo provides a mock function for the type WithFix
-func (_mock *WithFix) Foo() string {
- ret := _mock.Called()
-
- if len(ret) == 0 {
- panic("no return value specified for Foo")
- }
-
-
- var r0 string
- if returnFunc, ok := ret.Get(0).(func() string); ok {
- r0 = returnFunc()
- } else {
- r0 = ret.Get(0).(string)
- }
- return r0
-}
-
-
-
-// WithFix_Foo_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Foo'
-type WithFix_Foo_Call struct {
- *mock.Call
-}
-
-
-
-// Foo is a helper method to define mock.On call
-func (_e *WithFix_Expecter) Foo() *WithFix_Foo_Call {
- return &WithFix_Foo_Call{Call: _e.mock.On("Foo", )}
-}
-
-func (_c *WithFix_Foo_Call) Run(run func()) *WithFix_Foo_Call {
- _c.Call.Run(func(args mock.Arguments) {
- run()
- })
- return _c
-}
-
-func (_c *WithFix_Foo_Call) Return(s string) *WithFix_Foo_Call {
- _c.Call.Return(s)
- return _c
-}
-
-func (_c *WithFix_Foo_Call) RunAndReturn(run func()string) *WithFix_Foo_Call {
- _c.Call.Return(run)
- return _c
-}
-
-
diff --git a/internal/fixtures/test/issue_766_test.go b/internal/fixtures/issue_766_test.go
similarity index 72%
rename from internal/fixtures/test/issue_766_test.go
rename to internal/fixtures/issue_766_test.go
index 354f3afd..dfc7ec01 100644
--- a/internal/fixtures/test/issue_766_test.go
+++ b/internal/fixtures/issue_766_test.go
@@ -3,15 +3,12 @@ package test
import (
"testing"
- fixtures "github.com/vektra/mockery/v3/internal/fixtures"
-
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
- mocks "github.com/vektra/mockery/v3/mocks/github.com/vektra/mockery/v3/internal/fixtures"
)
// Asserts it implements the interface
-var _ fixtures.Issue766 = new(mocks.Issue766)
+var _ Issue766 = new(MockIssue766)
func TestIssue766(t *testing.T) {
fetchFunc := func(i ...int) ([]int, error) {
@@ -23,7 +20,7 @@ func TestIssue766(t *testing.T) {
}
expected := []int{1, 2, 3}
- mockFetchData := mocks.NewIssue766(t)
+ mockFetchData := NewMockIssue766(t)
mockFetchData.
EXPECT().
FetchData(mock.AnythingOfType("func(...int) ([]int, error)")).
diff --git a/internal/fixtures/method_args/same_name_arg_and_type/entity_test.go b/internal/fixtures/method_args/same_name_arg_and_type/entity_test.go
index 7ff6b929..1a83c445 100644
--- a/internal/fixtures/method_args/same_name_arg_and_type/entity_test.go
+++ b/internal/fixtures/method_args/same_name_arg_and_type/entity_test.go
@@ -28,8 +28,8 @@ func (s *testStruct) ExecDoB0v2() interfaceB0 {
func Test(t *testing.T) {
t.Run("ExecDoB", func(t *testing.T) {
- mockInterfaceB := new(interfaceBMock)
- mockInterfaceA := new(interfaceAMock)
+ mockInterfaceB := NewMockinterfaceB(t)
+ mockInterfaceA := NewMockinterfaceA(t)
mockInterfaceA.On("DoB", mock.Anything).Return(mockInterfaceB)
s := testStruct{
@@ -38,11 +38,10 @@ func Test(t *testing.T) {
res := s.ExecDoB()
assert.Equal(t, mockInterfaceB, res)
- mockInterfaceA.AssertExpectations(t)
})
t.Run("ExecDoB0", func(t *testing.T) {
- mockInterfaceB0 := new(interfaceB0Mock)
- mockInterfaceA := new(interfaceAMock)
+ mockInterfaceB0 := NewMockinterfaceB0(t)
+ mockInterfaceA := NewMockinterfaceA(t)
mockInterfaceA.On("DoB0", mock.Anything).Return(mockInterfaceB0)
s := testStruct{
@@ -51,11 +50,10 @@ func Test(t *testing.T) {
res := s.ExecDoB0()
assert.Equal(t, mockInterfaceB0, res)
- mockInterfaceA.AssertExpectations(t)
})
t.Run("ExecDoB0v2", func(t *testing.T) {
- mockInterfaceB0 := new(interfaceB0Mock)
- mockInterfaceA := new(interfaceAMock)
+ mockInterfaceB0 := NewMockinterfaceB0(t)
+ mockInterfaceA := NewMockinterfaceA(t)
mockInterfaceA.On("DoB0v2", mock.Anything).Return(mockInterfaceB0)
s := testStruct{
@@ -64,6 +62,5 @@ func Test(t *testing.T) {
res := s.ExecDoB0v2()
assert.Equal(t, mockInterfaceB0, res)
- mockInterfaceA.AssertExpectations(t)
})
}
diff --git a/internal/fixtures/method_args/same_name_arg_and_type/mock_interfaceA_test.go b/internal/fixtures/method_args/same_name_arg_and_type/mock_interfaceA_test.go
deleted file mode 100644
index 92f8dcf8..00000000
--- a/internal/fixtures/method_args/same_name_arg_and_type/mock_interfaceA_test.go
+++ /dev/null
@@ -1,200 +0,0 @@
-
-// Code generated by mockery; DO NOT EDIT.
-// github.com/vektra/mockery
-
-package same_name_arg_and_type
-
-import (
- mock "github.com/stretchr/testify/mock"
-)
-
-
-// NewinterfaceAMock creates a new instance of interfaceAMock. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
-// The first argument is typically a *testing.T value.
-func NewinterfaceAMock (t interface {
- mock.TestingT
- Cleanup(func())
-}) *interfaceAMock {
- mock := &interfaceAMock{}
- mock.Mock.Test(t)
-
- t.Cleanup(func() { mock.AssertExpectations(t) })
-
- return mock
-}
-
-
-// interfaceAMock is an autogenerated mock type for the interfaceA type
-type interfaceAMock struct {
- mock.Mock
-}
-
-type interfaceAMock_Expecter struct {
- mock *mock.Mock
-}
-
-func (_m *interfaceAMock) EXPECT() *interfaceAMock_Expecter {
- return &interfaceAMock_Expecter{mock: &_m.Mock}
-}
-
-
-
-// DoB provides a mock function for the type interfaceAMock
-func (_mock *interfaceAMock) DoB(interfaceB1 interfaceB) interfaceB {
- ret := _mock.Called(interfaceB1)
-
- if len(ret) == 0 {
- panic("no return value specified for DoB")
- }
-
-
- var r0 interfaceB
- if returnFunc, ok := ret.Get(0).(func(interfaceB) interfaceB); ok {
- r0 = returnFunc(interfaceB1)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(interfaceB)
- }
- }
- return r0
-}
-
-
-
-// interfaceAMock_DoB_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DoB'
-type interfaceAMock_DoB_Call struct {
- *mock.Call
-}
-
-
-
-// DoB is a helper method to define mock.On call
-// - interfaceB1
-func (_e *interfaceAMock_Expecter) DoB(interfaceB1 interface{}, ) *interfaceAMock_DoB_Call {
- return &interfaceAMock_DoB_Call{Call: _e.mock.On("DoB",interfaceB1, )}
-}
-
-func (_c *interfaceAMock_DoB_Call) Run(run func(interfaceB1 interfaceB)) *interfaceAMock_DoB_Call {
- _c.Call.Run(func(args mock.Arguments) {
- run(args[0].(interfaceB),)
- })
- return _c
-}
-
-func (_c *interfaceAMock_DoB_Call) Return(interfaceBMoqParam interfaceB) *interfaceAMock_DoB_Call {
- _c.Call.Return(interfaceBMoqParam)
- return _c
-}
-
-func (_c *interfaceAMock_DoB_Call) RunAndReturn(run func(interfaceB1 interfaceB)interfaceB) *interfaceAMock_DoB_Call {
- _c.Call.Return(run)
- return _c
-}
-
-
-// DoB0 provides a mock function for the type interfaceAMock
-func (_mock *interfaceAMock) DoB0(interfaceB interfaceB0) interfaceB0 {
- ret := _mock.Called(interfaceB)
-
- if len(ret) == 0 {
- panic("no return value specified for DoB0")
- }
-
-
- var r0 interfaceB0
- if returnFunc, ok := ret.Get(0).(func(interfaceB0) interfaceB0); ok {
- r0 = returnFunc(interfaceB)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(interfaceB0)
- }
- }
- return r0
-}
-
-
-
-// interfaceAMock_DoB0_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DoB0'
-type interfaceAMock_DoB0_Call struct {
- *mock.Call
-}
-
-
-
-// DoB0 is a helper method to define mock.On call
-// - interfaceB
-func (_e *interfaceAMock_Expecter) DoB0(interfaceB interface{}, ) *interfaceAMock_DoB0_Call {
- return &interfaceAMock_DoB0_Call{Call: _e.mock.On("DoB0",interfaceB, )}
-}
-
-func (_c *interfaceAMock_DoB0_Call) Run(run func(interfaceB interfaceB0)) *interfaceAMock_DoB0_Call {
- _c.Call.Run(func(args mock.Arguments) {
- run(args[0].(interfaceB0),)
- })
- return _c
-}
-
-func (_c *interfaceAMock_DoB0_Call) Return(interfaceB0MoqParam interfaceB0) *interfaceAMock_DoB0_Call {
- _c.Call.Return(interfaceB0MoqParam)
- return _c
-}
-
-func (_c *interfaceAMock_DoB0_Call) RunAndReturn(run func(interfaceB interfaceB0)interfaceB0) *interfaceAMock_DoB0_Call {
- _c.Call.Return(run)
- return _c
-}
-
-
-// DoB0v2 provides a mock function for the type interfaceAMock
-func (_mock *interfaceAMock) DoB0v2(interfaceB01 interfaceB0) interfaceB0 {
- ret := _mock.Called(interfaceB01)
-
- if len(ret) == 0 {
- panic("no return value specified for DoB0v2")
- }
-
-
- var r0 interfaceB0
- if returnFunc, ok := ret.Get(0).(func(interfaceB0) interfaceB0); ok {
- r0 = returnFunc(interfaceB01)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(interfaceB0)
- }
- }
- return r0
-}
-
-
-
-// interfaceAMock_DoB0v2_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DoB0v2'
-type interfaceAMock_DoB0v2_Call struct {
- *mock.Call
-}
-
-
-
-// DoB0v2 is a helper method to define mock.On call
-// - interfaceB01
-func (_e *interfaceAMock_Expecter) DoB0v2(interfaceB01 interface{}, ) *interfaceAMock_DoB0v2_Call {
- return &interfaceAMock_DoB0v2_Call{Call: _e.mock.On("DoB0v2",interfaceB01, )}
-}
-
-func (_c *interfaceAMock_DoB0v2_Call) Run(run func(interfaceB01 interfaceB0)) *interfaceAMock_DoB0v2_Call {
- _c.Call.Run(func(args mock.Arguments) {
- run(args[0].(interfaceB0),)
- })
- return _c
-}
-
-func (_c *interfaceAMock_DoB0v2_Call) Return(interfaceB0MoqParam interfaceB0) *interfaceAMock_DoB0v2_Call {
- _c.Call.Return(interfaceB0MoqParam)
- return _c
-}
-
-func (_c *interfaceAMock_DoB0v2_Call) RunAndReturn(run func(interfaceB01 interfaceB0)interfaceB0) *interfaceAMock_DoB0v2_Call {
- _c.Call.Return(run)
- return _c
-}
-
-
diff --git a/internal/fixtures/method_args/same_name_arg_and_type/mock_interfaceB0_test.go b/internal/fixtures/method_args/same_name_arg_and_type/mock_interfaceB0_test.go
deleted file mode 100644
index 2abb96b5..00000000
--- a/internal/fixtures/method_args/same_name_arg_and_type/mock_interfaceB0_test.go
+++ /dev/null
@@ -1,94 +0,0 @@
-
-// Code generated by mockery; DO NOT EDIT.
-// github.com/vektra/mockery
-
-package same_name_arg_and_type
-
-import (
- mock "github.com/stretchr/testify/mock"
-)
-
-
-// NewinterfaceB0Mock creates a new instance of interfaceB0Mock. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
-// The first argument is typically a *testing.T value.
-func NewinterfaceB0Mock (t interface {
- mock.TestingT
- Cleanup(func())
-}) *interfaceB0Mock {
- mock := &interfaceB0Mock{}
- mock.Mock.Test(t)
-
- t.Cleanup(func() { mock.AssertExpectations(t) })
-
- return mock
-}
-
-
-// interfaceB0Mock is an autogenerated mock type for the interfaceB0 type
-type interfaceB0Mock struct {
- mock.Mock
-}
-
-type interfaceB0Mock_Expecter struct {
- mock *mock.Mock
-}
-
-func (_m *interfaceB0Mock) EXPECT() *interfaceB0Mock_Expecter {
- return &interfaceB0Mock_Expecter{mock: &_m.Mock}
-}
-
-
-
-// DoB0 provides a mock function for the type interfaceB0Mock
-func (_mock *interfaceB0Mock) DoB0(interfaceB01 interfaceB0) interfaceB0 {
- ret := _mock.Called(interfaceB01)
-
- if len(ret) == 0 {
- panic("no return value specified for DoB0")
- }
-
-
- var r0 interfaceB0
- if returnFunc, ok := ret.Get(0).(func(interfaceB0) interfaceB0); ok {
- r0 = returnFunc(interfaceB01)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(interfaceB0)
- }
- }
- return r0
-}
-
-
-
-// interfaceB0Mock_DoB0_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DoB0'
-type interfaceB0Mock_DoB0_Call struct {
- *mock.Call
-}
-
-
-
-// DoB0 is a helper method to define mock.On call
-// - interfaceB01
-func (_e *interfaceB0Mock_Expecter) DoB0(interfaceB01 interface{}, ) *interfaceB0Mock_DoB0_Call {
- return &interfaceB0Mock_DoB0_Call{Call: _e.mock.On("DoB0",interfaceB01, )}
-}
-
-func (_c *interfaceB0Mock_DoB0_Call) Run(run func(interfaceB01 interfaceB0)) *interfaceB0Mock_DoB0_Call {
- _c.Call.Run(func(args mock.Arguments) {
- run(args[0].(interfaceB0),)
- })
- return _c
-}
-
-func (_c *interfaceB0Mock_DoB0_Call) Return(interfaceB0MoqParam interfaceB0) *interfaceB0Mock_DoB0_Call {
- _c.Call.Return(interfaceB0MoqParam)
- return _c
-}
-
-func (_c *interfaceB0Mock_DoB0_Call) RunAndReturn(run func(interfaceB01 interfaceB0)interfaceB0) *interfaceB0Mock_DoB0_Call {
- _c.Call.Return(run)
- return _c
-}
-
-
diff --git a/internal/fixtures/method_args/same_name_arg_and_type/mock_interfaceB_test.go b/internal/fixtures/method_args/same_name_arg_and_type/mock_interfaceB_test.go
deleted file mode 100644
index 28fe6d92..00000000
--- a/internal/fixtures/method_args/same_name_arg_and_type/mock_interfaceB_test.go
+++ /dev/null
@@ -1,91 +0,0 @@
-
-// Code generated by mockery; DO NOT EDIT.
-// github.com/vektra/mockery
-
-package same_name_arg_and_type
-
-import (
- mock "github.com/stretchr/testify/mock"
-)
-
-
-// NewinterfaceBMock creates a new instance of interfaceBMock. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
-// The first argument is typically a *testing.T value.
-func NewinterfaceBMock (t interface {
- mock.TestingT
- Cleanup(func())
-}) *interfaceBMock {
- mock := &interfaceBMock{}
- mock.Mock.Test(t)
-
- t.Cleanup(func() { mock.AssertExpectations(t) })
-
- return mock
-}
-
-
-// interfaceBMock is an autogenerated mock type for the interfaceB type
-type interfaceBMock struct {
- mock.Mock
-}
-
-type interfaceBMock_Expecter struct {
- mock *mock.Mock
-}
-
-func (_m *interfaceBMock) EXPECT() *interfaceBMock_Expecter {
- return &interfaceBMock_Expecter{mock: &_m.Mock}
-}
-
-
-
-// GetData provides a mock function for the type interfaceBMock
-func (_mock *interfaceBMock) GetData() int {
- ret := _mock.Called()
-
- if len(ret) == 0 {
- panic("no return value specified for GetData")
- }
-
-
- var r0 int
- if returnFunc, ok := ret.Get(0).(func() int); ok {
- r0 = returnFunc()
- } else {
- r0 = ret.Get(0).(int)
- }
- return r0
-}
-
-
-
-// interfaceBMock_GetData_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetData'
-type interfaceBMock_GetData_Call struct {
- *mock.Call
-}
-
-
-
-// GetData is a helper method to define mock.On call
-func (_e *interfaceBMock_Expecter) GetData() *interfaceBMock_GetData_Call {
- return &interfaceBMock_GetData_Call{Call: _e.mock.On("GetData", )}
-}
-
-func (_c *interfaceBMock_GetData_Call) Run(run func()) *interfaceBMock_GetData_Call {
- _c.Call.Run(func(args mock.Arguments) {
- run()
- })
- return _c
-}
-
-func (_c *interfaceBMock_GetData_Call) Return(n int) *interfaceBMock_GetData_Call {
- _c.Call.Return(n)
- return _c
-}
-
-func (_c *interfaceBMock_GetData_Call) RunAndReturn(run func()int) *interfaceBMock_GetData_Call {
- _c.Call.Return(run)
- return _c
-}
-
-
diff --git a/internal/fixtures/method_args/same_name_arg_and_type/mocks_test.go b/internal/fixtures/method_args/same_name_arg_and_type/mocks_test.go
new file mode 100644
index 00000000..8c793f39
--- /dev/null
+++ b/internal/fixtures/method_args/same_name_arg_and_type/mocks_test.go
@@ -0,0 +1,361 @@
+
+// Code generated by mockery; DO NOT EDIT.
+// github.com/vektra/mockery
+
+package same_name_arg_and_type
+
+import (
+ mock "github.com/stretchr/testify/mock"
+)
+
+
+// NewMockinterfaceA creates a new instance of MockinterfaceA. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
+// The first argument is typically a *testing.T value.
+func NewMockinterfaceA (t interface {
+ mock.TestingT
+ Cleanup(func())
+}) *MockinterfaceA {
+ mock := &MockinterfaceA{}
+ mock.Mock.Test(t)
+
+ t.Cleanup(func() { mock.AssertExpectations(t) })
+
+ return mock
+}
+
+
+// MockinterfaceA is an autogenerated mock type for the interfaceA type
+type MockinterfaceA struct {
+ mock.Mock
+}
+
+type MockinterfaceA_Expecter struct {
+ mock *mock.Mock
+}
+
+func (_m *MockinterfaceA) EXPECT() *MockinterfaceA_Expecter {
+ return &MockinterfaceA_Expecter{mock: &_m.Mock}
+}
+
+
+
+// DoB provides a mock function for the type MockinterfaceA
+func (_mock *MockinterfaceA) DoB(interfaceB1 interfaceB) interfaceB {
+ ret := _mock.Called(interfaceB1)
+
+ if len(ret) == 0 {
+ panic("no return value specified for DoB")
+ }
+
+
+ var r0 interfaceB
+ if returnFunc, ok := ret.Get(0).(func(interfaceB) interfaceB); ok {
+ r0 = returnFunc(interfaceB1)
+ } else {
+ if ret.Get(0) != nil {
+ r0 = ret.Get(0).(interfaceB)
+ }
+ }
+ return r0
+}
+
+
+
+// MockinterfaceA_DoB_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DoB'
+type MockinterfaceA_DoB_Call struct {
+ *mock.Call
+}
+
+
+
+// DoB is a helper method to define mock.On call
+// - interfaceB1
+func (_e *MockinterfaceA_Expecter) DoB(interfaceB1 interface{}, ) *MockinterfaceA_DoB_Call {
+ return &MockinterfaceA_DoB_Call{Call: _e.mock.On("DoB",interfaceB1, )}
+}
+
+func (_c *MockinterfaceA_DoB_Call) Run(run func(interfaceB1 interfaceB)) *MockinterfaceA_DoB_Call {
+ _c.Call.Run(func(args mock.Arguments) {
+ run(args[0].(interfaceB),)
+ })
+ return _c
+}
+
+func (_c *MockinterfaceA_DoB_Call) Return(interfaceBMoqParam interfaceB) *MockinterfaceA_DoB_Call {
+ _c.Call.Return(interfaceBMoqParam)
+ return _c
+}
+
+func (_c *MockinterfaceA_DoB_Call) RunAndReturn(run func(interfaceB1 interfaceB)interfaceB) *MockinterfaceA_DoB_Call {
+ _c.Call.Return(run)
+ return _c
+}
+
+
+// DoB0 provides a mock function for the type MockinterfaceA
+func (_mock *MockinterfaceA) DoB0(interfaceB interfaceB0) interfaceB0 {
+ ret := _mock.Called(interfaceB)
+
+ if len(ret) == 0 {
+ panic("no return value specified for DoB0")
+ }
+
+
+ var r0 interfaceB0
+ if returnFunc, ok := ret.Get(0).(func(interfaceB0) interfaceB0); ok {
+ r0 = returnFunc(interfaceB)
+ } else {
+ if ret.Get(0) != nil {
+ r0 = ret.Get(0).(interfaceB0)
+ }
+ }
+ return r0
+}
+
+
+
+// MockinterfaceA_DoB0_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DoB0'
+type MockinterfaceA_DoB0_Call struct {
+ *mock.Call
+}
+
+
+
+// DoB0 is a helper method to define mock.On call
+// - interfaceB
+func (_e *MockinterfaceA_Expecter) DoB0(interfaceB interface{}, ) *MockinterfaceA_DoB0_Call {
+ return &MockinterfaceA_DoB0_Call{Call: _e.mock.On("DoB0",interfaceB, )}
+}
+
+func (_c *MockinterfaceA_DoB0_Call) Run(run func(interfaceB interfaceB0)) *MockinterfaceA_DoB0_Call {
+ _c.Call.Run(func(args mock.Arguments) {
+ run(args[0].(interfaceB0),)
+ })
+ return _c
+}
+
+func (_c *MockinterfaceA_DoB0_Call) Return(interfaceB0MoqParam interfaceB0) *MockinterfaceA_DoB0_Call {
+ _c.Call.Return(interfaceB0MoqParam)
+ return _c
+}
+
+func (_c *MockinterfaceA_DoB0_Call) RunAndReturn(run func(interfaceB interfaceB0)interfaceB0) *MockinterfaceA_DoB0_Call {
+ _c.Call.Return(run)
+ return _c
+}
+
+
+// DoB0v2 provides a mock function for the type MockinterfaceA
+func (_mock *MockinterfaceA) DoB0v2(interfaceB01 interfaceB0) interfaceB0 {
+ ret := _mock.Called(interfaceB01)
+
+ if len(ret) == 0 {
+ panic("no return value specified for DoB0v2")
+ }
+
+
+ var r0 interfaceB0
+ if returnFunc, ok := ret.Get(0).(func(interfaceB0) interfaceB0); ok {
+ r0 = returnFunc(interfaceB01)
+ } else {
+ if ret.Get(0) != nil {
+ r0 = ret.Get(0).(interfaceB0)
+ }
+ }
+ return r0
+}
+
+
+
+// MockinterfaceA_DoB0v2_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DoB0v2'
+type MockinterfaceA_DoB0v2_Call struct {
+ *mock.Call
+}
+
+
+
+// DoB0v2 is a helper method to define mock.On call
+// - interfaceB01
+func (_e *MockinterfaceA_Expecter) DoB0v2(interfaceB01 interface{}, ) *MockinterfaceA_DoB0v2_Call {
+ return &MockinterfaceA_DoB0v2_Call{Call: _e.mock.On("DoB0v2",interfaceB01, )}
+}
+
+func (_c *MockinterfaceA_DoB0v2_Call) Run(run func(interfaceB01 interfaceB0)) *MockinterfaceA_DoB0v2_Call {
+ _c.Call.Run(func(args mock.Arguments) {
+ run(args[0].(interfaceB0),)
+ })
+ return _c
+}
+
+func (_c *MockinterfaceA_DoB0v2_Call) Return(interfaceB0MoqParam interfaceB0) *MockinterfaceA_DoB0v2_Call {
+ _c.Call.Return(interfaceB0MoqParam)
+ return _c
+}
+
+func (_c *MockinterfaceA_DoB0v2_Call) RunAndReturn(run func(interfaceB01 interfaceB0)interfaceB0) *MockinterfaceA_DoB0v2_Call {
+ _c.Call.Return(run)
+ return _c
+}
+
+// NewMockinterfaceB creates a new instance of MockinterfaceB. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
+// The first argument is typically a *testing.T value.
+func NewMockinterfaceB (t interface {
+ mock.TestingT
+ Cleanup(func())
+}) *MockinterfaceB {
+ mock := &MockinterfaceB{}
+ mock.Mock.Test(t)
+
+ t.Cleanup(func() { mock.AssertExpectations(t) })
+
+ return mock
+}
+
+
+// MockinterfaceB is an autogenerated mock type for the interfaceB type
+type MockinterfaceB struct {
+ mock.Mock
+}
+
+type MockinterfaceB_Expecter struct {
+ mock *mock.Mock
+}
+
+func (_m *MockinterfaceB) EXPECT() *MockinterfaceB_Expecter {
+ return &MockinterfaceB_Expecter{mock: &_m.Mock}
+}
+
+
+
+// GetData provides a mock function for the type MockinterfaceB
+func (_mock *MockinterfaceB) GetData() int {
+ ret := _mock.Called()
+
+ if len(ret) == 0 {
+ panic("no return value specified for GetData")
+ }
+
+
+ var r0 int
+ if returnFunc, ok := ret.Get(0).(func() int); ok {
+ r0 = returnFunc()
+ } else {
+ r0 = ret.Get(0).(int)
+ }
+ return r0
+}
+
+
+
+// MockinterfaceB_GetData_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetData'
+type MockinterfaceB_GetData_Call struct {
+ *mock.Call
+}
+
+
+
+// GetData is a helper method to define mock.On call
+func (_e *MockinterfaceB_Expecter) GetData() *MockinterfaceB_GetData_Call {
+ return &MockinterfaceB_GetData_Call{Call: _e.mock.On("GetData", )}
+}
+
+func (_c *MockinterfaceB_GetData_Call) Run(run func()) *MockinterfaceB_GetData_Call {
+ _c.Call.Run(func(args mock.Arguments) {
+ run()
+ })
+ return _c
+}
+
+func (_c *MockinterfaceB_GetData_Call) Return(n int) *MockinterfaceB_GetData_Call {
+ _c.Call.Return(n)
+ return _c
+}
+
+func (_c *MockinterfaceB_GetData_Call) RunAndReturn(run func()int) *MockinterfaceB_GetData_Call {
+ _c.Call.Return(run)
+ return _c
+}
+
+// NewMockinterfaceB0 creates a new instance of MockinterfaceB0. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
+// The first argument is typically a *testing.T value.
+func NewMockinterfaceB0 (t interface {
+ mock.TestingT
+ Cleanup(func())
+}) *MockinterfaceB0 {
+ mock := &MockinterfaceB0{}
+ mock.Mock.Test(t)
+
+ t.Cleanup(func() { mock.AssertExpectations(t) })
+
+ return mock
+}
+
+
+// MockinterfaceB0 is an autogenerated mock type for the interfaceB0 type
+type MockinterfaceB0 struct {
+ mock.Mock
+}
+
+type MockinterfaceB0_Expecter struct {
+ mock *mock.Mock
+}
+
+func (_m *MockinterfaceB0) EXPECT() *MockinterfaceB0_Expecter {
+ return &MockinterfaceB0_Expecter{mock: &_m.Mock}
+}
+
+
+
+// DoB0 provides a mock function for the type MockinterfaceB0
+func (_mock *MockinterfaceB0) DoB0(interfaceB01 interfaceB0) interfaceB0 {
+ ret := _mock.Called(interfaceB01)
+
+ if len(ret) == 0 {
+ panic("no return value specified for DoB0")
+ }
+
+
+ var r0 interfaceB0
+ if returnFunc, ok := ret.Get(0).(func(interfaceB0) interfaceB0); ok {
+ r0 = returnFunc(interfaceB01)
+ } else {
+ if ret.Get(0) != nil {
+ r0 = ret.Get(0).(interfaceB0)
+ }
+ }
+ return r0
+}
+
+
+
+// MockinterfaceB0_DoB0_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DoB0'
+type MockinterfaceB0_DoB0_Call struct {
+ *mock.Call
+}
+
+
+
+// DoB0 is a helper method to define mock.On call
+// - interfaceB01
+func (_e *MockinterfaceB0_Expecter) DoB0(interfaceB01 interface{}, ) *MockinterfaceB0_DoB0_Call {
+ return &MockinterfaceB0_DoB0_Call{Call: _e.mock.On("DoB0",interfaceB01, )}
+}
+
+func (_c *MockinterfaceB0_DoB0_Call) Run(run func(interfaceB01 interfaceB0)) *MockinterfaceB0_DoB0_Call {
+ _c.Call.Run(func(args mock.Arguments) {
+ run(args[0].(interfaceB0),)
+ })
+ return _c
+}
+
+func (_c *MockinterfaceB0_DoB0_Call) Return(interfaceB0MoqParam interfaceB0) *MockinterfaceB0_DoB0_Call {
+ _c.Call.Return(interfaceB0MoqParam)
+ return _c
+}
+
+func (_c *MockinterfaceB0_DoB0_Call) RunAndReturn(run func(interfaceB01 interfaceB0)interfaceB0) *MockinterfaceB0_DoB0_Call {
+ _c.Call.Return(run)
+ return _c
+}
+
+
diff --git a/internal/fixtures/mocks.go b/internal/fixtures/mocks_test.go
similarity index 100%
rename from internal/fixtures/mocks.go
rename to internal/fixtures/mocks_test.go
diff --git a/internal/fixtures/recursive_generation/Foo_mock.go b/internal/fixtures/recursive_generation/mocks_test.go
similarity index 100%
rename from internal/fixtures/recursive_generation/Foo_mock.go
rename to internal/fixtures/recursive_generation/mocks_test.go
diff --git a/internal/fixtures/recursive_generation/subpkg1/Foo_mock.go b/internal/fixtures/recursive_generation/subpkg1/Foo_mock.go
deleted file mode 100644
index aad18ecf..00000000
--- a/internal/fixtures/recursive_generation/subpkg1/Foo_mock.go
+++ /dev/null
@@ -1,91 +0,0 @@
-
-// Code generated by mockery; DO NOT EDIT.
-// github.com/vektra/mockery
-
-package subpkg1
-
-import (
- mock "github.com/stretchr/testify/mock"
-)
-
-
-// NewMockFoo creates a new instance of MockFoo. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
-// The first argument is typically a *testing.T value.
-func NewMockFoo (t interface {
- mock.TestingT
- Cleanup(func())
-}) *MockFoo {
- mock := &MockFoo{}
- mock.Mock.Test(t)
-
- t.Cleanup(func() { mock.AssertExpectations(t) })
-
- return mock
-}
-
-
-// MockFoo is an autogenerated mock type for the Foo type
-type MockFoo struct {
- mock.Mock
-}
-
-type MockFoo_Expecter struct {
- mock *mock.Mock
-}
-
-func (_m *MockFoo) EXPECT() *MockFoo_Expecter {
- return &MockFoo_Expecter{mock: &_m.Mock}
-}
-
-
-
-// Get provides a mock function for the type MockFoo
-func (_mock *MockFoo) Get() string {
- ret := _mock.Called()
-
- if len(ret) == 0 {
- panic("no return value specified for Get")
- }
-
-
- var r0 string
- if returnFunc, ok := ret.Get(0).(func() string); ok {
- r0 = returnFunc()
- } else {
- r0 = ret.Get(0).(string)
- }
- return r0
-}
-
-
-
-// MockFoo_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get'
-type MockFoo_Get_Call struct {
- *mock.Call
-}
-
-
-
-// Get is a helper method to define mock.On call
-func (_e *MockFoo_Expecter) Get() *MockFoo_Get_Call {
- return &MockFoo_Get_Call{Call: _e.mock.On("Get", )}
-}
-
-func (_c *MockFoo_Get_Call) Run(run func()) *MockFoo_Get_Call {
- _c.Call.Run(func(args mock.Arguments) {
- run()
- })
- return _c
-}
-
-func (_c *MockFoo_Get_Call) Return(s string) *MockFoo_Get_Call {
- _c.Call.Return(s)
- return _c
-}
-
-func (_c *MockFoo_Get_Call) RunAndReturn(run func()string) *MockFoo_Get_Call {
- _c.Call.Return(run)
- return _c
-}
-
-
diff --git a/internal/fixtures/recursive_generation/subpkg2/Foo_mock.go b/internal/fixtures/recursive_generation/subpkg2/Foo_mock.go
deleted file mode 100644
index b02443cb..00000000
--- a/internal/fixtures/recursive_generation/subpkg2/Foo_mock.go
+++ /dev/null
@@ -1,91 +0,0 @@
-
-// Code generated by mockery; DO NOT EDIT.
-// github.com/vektra/mockery
-
-package subpkg2
-
-import (
- mock "github.com/stretchr/testify/mock"
-)
-
-
-// NewMockFoo creates a new instance of MockFoo. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
-// The first argument is typically a *testing.T value.
-func NewMockFoo (t interface {
- mock.TestingT
- Cleanup(func())
-}) *MockFoo {
- mock := &MockFoo{}
- mock.Mock.Test(t)
-
- t.Cleanup(func() { mock.AssertExpectations(t) })
-
- return mock
-}
-
-
-// MockFoo is an autogenerated mock type for the Foo type
-type MockFoo struct {
- mock.Mock
-}
-
-type MockFoo_Expecter struct {
- mock *mock.Mock
-}
-
-func (_m *MockFoo) EXPECT() *MockFoo_Expecter {
- return &MockFoo_Expecter{mock: &_m.Mock}
-}
-
-
-
-// Get provides a mock function for the type MockFoo
-func (_mock *MockFoo) Get() string {
- ret := _mock.Called()
-
- if len(ret) == 0 {
- panic("no return value specified for Get")
- }
-
-
- var r0 string
- if returnFunc, ok := ret.Get(0).(func() string); ok {
- r0 = returnFunc()
- } else {
- r0 = ret.Get(0).(string)
- }
- return r0
-}
-
-
-
-// MockFoo_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get'
-type MockFoo_Get_Call struct {
- *mock.Call
-}
-
-
-
-// Get is a helper method to define mock.On call
-func (_e *MockFoo_Expecter) Get() *MockFoo_Get_Call {
- return &MockFoo_Get_Call{Call: _e.mock.On("Get", )}
-}
-
-func (_c *MockFoo_Get_Call) Run(run func()) *MockFoo_Get_Call {
- _c.Call.Run(func(args mock.Arguments) {
- run()
- })
- return _c
-}
-
-func (_c *MockFoo_Get_Call) Return(s string) *MockFoo_Get_Call {
- _c.Call.Return(s)
- return _c
-}
-
-func (_c *MockFoo_Get_Call) RunAndReturn(run func()string) *MockFoo_Get_Call {
- _c.Call.Return(run)
- return _c
-}
-
-
diff --git a/internal/fixtures/recursive_generation/subpkg_with_only_autogenerated_files/Foo_mock.go b/internal/fixtures/recursive_generation/subpkg_with_only_autogenerated_files/Foo_mock.go
deleted file mode 100644
index 2848d1fa..00000000
--- a/internal/fixtures/recursive_generation/subpkg_with_only_autogenerated_files/Foo_mock.go
+++ /dev/null
@@ -1,91 +0,0 @@
-
-// Code generated by mockery; DO NOT EDIT.
-// github.com/vektra/mockery
-
-package subpkg_with_only_autogenerated_files
-
-import (
- mock "github.com/stretchr/testify/mock"
-)
-
-
-// NewMockFoo creates a new instance of MockFoo. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
-// The first argument is typically a *testing.T value.
-func NewMockFoo (t interface {
- mock.TestingT
- Cleanup(func())
-}) *MockFoo {
- mock := &MockFoo{}
- mock.Mock.Test(t)
-
- t.Cleanup(func() { mock.AssertExpectations(t) })
-
- return mock
-}
-
-
-// MockFoo is an autogenerated mock type for the Foo type
-type MockFoo struct {
- mock.Mock
-}
-
-type MockFoo_Expecter struct {
- mock *mock.Mock
-}
-
-func (_m *MockFoo) EXPECT() *MockFoo_Expecter {
- return &MockFoo_Expecter{mock: &_m.Mock}
-}
-
-
-
-// Get provides a mock function for the type MockFoo
-func (_mock *MockFoo) Get() string {
- ret := _mock.Called()
-
- if len(ret) == 0 {
- panic("no return value specified for Get")
- }
-
-
- var r0 string
- if returnFunc, ok := ret.Get(0).(func() string); ok {
- r0 = returnFunc()
- } else {
- r0 = ret.Get(0).(string)
- }
- return r0
-}
-
-
-
-// MockFoo_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get'
-type MockFoo_Get_Call struct {
- *mock.Call
-}
-
-
-
-// Get is a helper method to define mock.On call
-func (_e *MockFoo_Expecter) Get() *MockFoo_Get_Call {
- return &MockFoo_Get_Call{Call: _e.mock.On("Get", )}
-}
-
-func (_c *MockFoo_Get_Call) Run(run func()) *MockFoo_Get_Call {
- _c.Call.Run(func(args mock.Arguments) {
- run()
- })
- return _c
-}
-
-func (_c *MockFoo_Get_Call) Return(s string) *MockFoo_Get_Call {
- _c.Call.Return(s)
- return _c
-}
-
-func (_c *MockFoo_Get_Call) RunAndReturn(run func()string) *MockFoo_Get_Call {
- _c.Call.Return(run)
- return _c
-}
-
-
diff --git a/internal/fixtures/type_alias/mock_Interface1_test.go b/internal/fixtures/type_alias/mock_Interface1_test.go
deleted file mode 100644
index 4e7fae51..00000000
--- a/internal/fixtures/type_alias/mock_Interface1_test.go
+++ /dev/null
@@ -1,92 +0,0 @@
-
-// Code generated by mockery; DO NOT EDIT.
-// github.com/vektra/mockery
-
-package type_alias_test
-
-import (
- "github.com/vektra/mockery/v3/internal/fixtures/type_alias"
- mock "github.com/stretchr/testify/mock"
-)
-
-
-// NewInterface1 creates a new instance of Interface1. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
-// The first argument is typically a *testing.T value.
-func NewInterface1 (t interface {
- mock.TestingT
- Cleanup(func())
-}) *Interface1 {
- mock := &Interface1{}
- mock.Mock.Test(t)
-
- t.Cleanup(func() { mock.AssertExpectations(t) })
-
- return mock
-}
-
-
-// Interface1 is an autogenerated mock type for the Interface1 type
-type Interface1 struct {
- mock.Mock
-}
-
-type Interface1_Expecter struct {
- mock *mock.Mock
-}
-
-func (_m *Interface1) EXPECT() *Interface1_Expecter {
- return &Interface1_Expecter{mock: &_m.Mock}
-}
-
-
-
-// Foo provides a mock function for the type Interface1
-func (_mock *Interface1) Foo() type_alias.Type {
- ret := _mock.Called()
-
- if len(ret) == 0 {
- panic("no return value specified for Foo")
- }
-
-
- var r0 type_alias.Type
- if returnFunc, ok := ret.Get(0).(func() type_alias.Type); ok {
- r0 = returnFunc()
- } else {
- r0 = ret.Get(0).(type_alias.Type)
- }
- return r0
-}
-
-
-
-// Interface1_Foo_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Foo'
-type Interface1_Foo_Call struct {
- *mock.Call
-}
-
-
-
-// Foo is a helper method to define mock.On call
-func (_e *Interface1_Expecter) Foo() *Interface1_Foo_Call {
- return &Interface1_Foo_Call{Call: _e.mock.On("Foo", )}
-}
-
-func (_c *Interface1_Foo_Call) Run(run func()) *Interface1_Foo_Call {
- _c.Call.Run(func(args mock.Arguments) {
- run()
- })
- return _c
-}
-
-func (_c *Interface1_Foo_Call) Return(v type_alias.Type) *Interface1_Foo_Call {
- _c.Call.Return(v)
- return _c
-}
-
-func (_c *Interface1_Foo_Call) RunAndReturn(run func()type_alias.Type) *Interface1_Foo_Call {
- _c.Call.Return(run)
- return _c
-}
-
-
diff --git a/internal/fixtures/type_alias/mock_Interface2_test.go b/internal/fixtures/type_alias/mock_Interface2_test.go
deleted file mode 100644
index b52a7453..00000000
--- a/internal/fixtures/type_alias/mock_Interface2_test.go
+++ /dev/null
@@ -1,83 +0,0 @@
-
-// Code generated by mockery; DO NOT EDIT.
-// github.com/vektra/mockery
-
-package type_alias_test
-
-import (
- "github.com/vektra/mockery/v3/internal/fixtures/type_alias"
- "github.com/vektra/mockery/v3/internal/fixtures/type_alias/subpkg"
- mock "github.com/stretchr/testify/mock"
-)
-
-
-// NewInterface2 creates a new instance of Interface2. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
-// The first argument is typically a *testing.T value.
-func NewInterface2 (t interface {
- mock.TestingT
- Cleanup(func())
-}) *Interface2 {
- mock := &Interface2{}
- mock.Mock.Test(t)
-
- t.Cleanup(func() { mock.AssertExpectations(t) })
-
- return mock
-}
-
-
-// Interface2 is an autogenerated mock type for the Interface2 type
-type Interface2 struct {
- mock.Mock
-}
-
-type Interface2_Expecter struct {
- mock *mock.Mock
-}
-
-func (_m *Interface2) EXPECT() *Interface2_Expecter {
- return &Interface2_Expecter{mock: &_m.Mock}
-}
-
-
-
-// F provides a mock function for the type Interface2
-func (_mock *Interface2) F(v type_alias.Type, v1 type_alias.S, s subpkg.S) { _mock.Called(v, v1, s)
- return
-}
-
-
-
-// Interface2_F_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'F'
-type Interface2_F_Call struct {
- *mock.Call
-}
-
-
-
-// F is a helper method to define mock.On call
-// - v
-// - v1
-// - s
-func (_e *Interface2_Expecter) F(v interface{}, v1 interface{}, s interface{}, ) *Interface2_F_Call {
- return &Interface2_F_Call{Call: _e.mock.On("F",v,v1,s, )}
-}
-
-func (_c *Interface2_F_Call) Run(run func(v type_alias.Type, v1 type_alias.S, s subpkg.S)) *Interface2_F_Call {
- _c.Call.Run(func(args mock.Arguments) {
- run(args[0].(type_alias.Type),args[1].(type_alias.S),args[2].(subpkg.S),)
- })
- return _c
-}
-
-func (_c *Interface2_F_Call) Return() *Interface2_F_Call {
- _c.Call.Return()
- return _c
-}
-
-func (_c *Interface2_F_Call) RunAndReturn(run func(v type_alias.Type, v1 type_alias.S, s subpkg.S)) *Interface2_F_Call {
- _c.Run(run)
- return _c
-}
-
-
diff --git a/internal/fixtures/type_alias/mocks_test.go b/internal/fixtures/type_alias/mocks_test.go
new file mode 100644
index 00000000..974495f0
--- /dev/null
+++ b/internal/fixtures/type_alias/mocks_test.go
@@ -0,0 +1,161 @@
+
+// Code generated by mockery; DO NOT EDIT.
+// github.com/vektra/mockery
+
+package type_alias
+
+import (
+ "github.com/vektra/mockery/v3/internal/fixtures/type_alias/subpkg"
+ mock "github.com/stretchr/testify/mock"
+)
+
+
+// NewMockInterface1 creates a new instance of MockInterface1. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
+// The first argument is typically a *testing.T value.
+func NewMockInterface1 (t interface {
+ mock.TestingT
+ Cleanup(func())
+}) *MockInterface1 {
+ mock := &MockInterface1{}
+ mock.Mock.Test(t)
+
+ t.Cleanup(func() { mock.AssertExpectations(t) })
+
+ return mock
+}
+
+
+// MockInterface1 is an autogenerated mock type for the Interface1 type
+type MockInterface1 struct {
+ mock.Mock
+}
+
+type MockInterface1_Expecter struct {
+ mock *mock.Mock
+}
+
+func (_m *MockInterface1) EXPECT() *MockInterface1_Expecter {
+ return &MockInterface1_Expecter{mock: &_m.Mock}
+}
+
+
+
+// Foo provides a mock function for the type MockInterface1
+func (_mock *MockInterface1) Foo() Type {
+ ret := _mock.Called()
+
+ if len(ret) == 0 {
+ panic("no return value specified for Foo")
+ }
+
+
+ var r0 Type
+ if returnFunc, ok := ret.Get(0).(func() Type); ok {
+ r0 = returnFunc()
+ } else {
+ r0 = ret.Get(0).(Type)
+ }
+ return r0
+}
+
+
+
+// MockInterface1_Foo_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Foo'
+type MockInterface1_Foo_Call struct {
+ *mock.Call
+}
+
+
+
+// Foo is a helper method to define mock.On call
+func (_e *MockInterface1_Expecter) Foo() *MockInterface1_Foo_Call {
+ return &MockInterface1_Foo_Call{Call: _e.mock.On("Foo", )}
+}
+
+func (_c *MockInterface1_Foo_Call) Run(run func()) *MockInterface1_Foo_Call {
+ _c.Call.Run(func(args mock.Arguments) {
+ run()
+ })
+ return _c
+}
+
+func (_c *MockInterface1_Foo_Call) Return(v Type) *MockInterface1_Foo_Call {
+ _c.Call.Return(v)
+ return _c
+}
+
+func (_c *MockInterface1_Foo_Call) RunAndReturn(run func()Type) *MockInterface1_Foo_Call {
+ _c.Call.Return(run)
+ return _c
+}
+
+// NewMockInterface2 creates a new instance of MockInterface2. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
+// The first argument is typically a *testing.T value.
+func NewMockInterface2 (t interface {
+ mock.TestingT
+ Cleanup(func())
+}) *MockInterface2 {
+ mock := &MockInterface2{}
+ mock.Mock.Test(t)
+
+ t.Cleanup(func() { mock.AssertExpectations(t) })
+
+ return mock
+}
+
+
+// MockInterface2 is an autogenerated mock type for the Interface2 type
+type MockInterface2 struct {
+ mock.Mock
+}
+
+type MockInterface2_Expecter struct {
+ mock *mock.Mock
+}
+
+func (_m *MockInterface2) EXPECT() *MockInterface2_Expecter {
+ return &MockInterface2_Expecter{mock: &_m.Mock}
+}
+
+
+
+// F provides a mock function for the type MockInterface2
+func (_mock *MockInterface2) F(v Type, v1 S, s subpkg.S) { _mock.Called(v, v1, s)
+ return
+}
+
+
+
+// MockInterface2_F_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'F'
+type MockInterface2_F_Call struct {
+ *mock.Call
+}
+
+
+
+// F is a helper method to define mock.On call
+// - v
+// - v1
+// - s
+func (_e *MockInterface2_Expecter) F(v interface{}, v1 interface{}, s interface{}, ) *MockInterface2_F_Call {
+ return &MockInterface2_F_Call{Call: _e.mock.On("F",v,v1,s, )}
+}
+
+func (_c *MockInterface2_F_Call) Run(run func(v Type, v1 S, s subpkg.S)) *MockInterface2_F_Call {
+ _c.Call.Run(func(args mock.Arguments) {
+ run(args[0].(Type),args[1].(S),args[2].(subpkg.S),)
+ })
+ return _c
+}
+
+func (_c *MockInterface2_F_Call) Return() *MockInterface2_F_Call {
+ _c.Call.Return()
+ return _c
+}
+
+func (_c *MockInterface2_F_Call) RunAndReturn(run func(v Type, v1 S, s subpkg.S)) *MockInterface2_F_Call {
+ _c.Run(run)
+ return _c
+}
+
+
diff --git a/internal/fixtures/test/variadic_return_func_test.go b/internal/fixtures/variadic_return_func_test.go
similarity index 74%
rename from internal/fixtures/test/variadic_return_func_test.go
rename to internal/fixtures/variadic_return_func_test.go
index 7e38a9a0..8f80118c 100644
--- a/internal/fixtures/test/variadic_return_func_test.go
+++ b/internal/fixtures/variadic_return_func_test.go
@@ -4,11 +4,10 @@ import (
"testing"
"github.com/stretchr/testify/assert"
- mocks "github.com/vektra/mockery/v3/mocks/github.com/vektra/mockery/v3/internal/fixtures"
)
func TestVariadicReturnFunc(t *testing.T) {
- m := mocks.NewVariadicReturnFunc(t)
+ m := NewMockVariadicReturnFunc(t)
m.EXPECT().SampleMethod("").Return(func(s string, l []int, a ...any) {
assert.Equal(t, "foo", s)
assert.Equal(t, []int{1, 2, 3}, l)
diff --git a/internal/template_generator.go b/internal/template_generator.go
index 2c924e08..7b982906 100644
--- a/internal/template_generator.go
+++ b/internal/template_generator.go
@@ -191,7 +191,7 @@ func (g *TemplateGenerator) methodData(ctx context.Context, method *types.Func)
}
params[j] = template.ParamData{
- Var: methodScope.AddVar(ctx, param, ""),
+ Var: methodScope.AddVar(param, ""),
Variadic: signature.Variadic() && j == signature.Params().Len()-1,
}
}
@@ -200,7 +200,7 @@ func (g *TemplateGenerator) methodData(ctx context.Context, method *types.Func)
for j := 0; j < signature.Results().Len(); j++ {
param := signature.Results().At(j)
returns[j] = template.ParamData{
- Var: methodScope.AddVar(ctx, param, ""),
+ Var: methodScope.AddVar(param, ""),
Variadic: false,
}
}
@@ -241,7 +241,7 @@ func (g *TemplateGenerator) typeParams(ctx context.Context, tparams *types.TypeP
tp := tparams.At(i)
typeParam := types.NewParam(token.Pos(i), tp.Obj().Pkg(), tp.Obj().Name(), tp.Constraint())
tpd[i] = template.TypeParamData{
- ParamData: template.ParamData{Var: scope.AddVar(ctx, typeParam, "")},
+ ParamData: template.ParamData{Var: scope.AddVar(typeParam, "")},
Constraint: explicitConstraintType(typeParam),
}
}
diff --git a/mockery-tools.env b/mockery-tools.env
index 720daa4c..59d6cbbb 100644
--- a/mockery-tools.env
+++ b/mockery-tools.env
@@ -1 +1 @@
-VERSION=v3.0.0-alpha.10
+VERSION=v3.0.0-alpha.11
diff --git a/mocks/github.com/vektra/mockery/v3/internal/fixtures/buildtag/comment/IfaceWithCustomBuildTagInComment_mock.go b/mocks/github.com/vektra/mockery/v3/internal/fixtures/buildtag/comment/IfaceWithCustomBuildTagInComment_mock.go
deleted file mode 100644
index ee99ad99..00000000
--- a/mocks/github.com/vektra/mockery/v3/internal/fixtures/buildtag/comment/IfaceWithCustomBuildTagInComment_mock.go
+++ /dev/null
@@ -1,143 +0,0 @@
-
-// Code generated by mockery; DO NOT EDIT.
-// github.com/vektra/mockery
-
-//go:build custom3 && (!windows || !darwin || !freebsd)
-
-package mocks
-
-import (
- mock "github.com/stretchr/testify/mock"
-)
-
-
-// NewIfaceWithCustomBuildTagInComment creates a new instance of IfaceWithCustomBuildTagInComment. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
-// The first argument is typically a *testing.T value.
-func NewIfaceWithCustomBuildTagInComment (t interface {
- mock.TestingT
- Cleanup(func())
-}) *IfaceWithCustomBuildTagInComment {
- mock := &IfaceWithCustomBuildTagInComment{}
- mock.Mock.Test(t)
-
- t.Cleanup(func() { mock.AssertExpectations(t) })
-
- return mock
-}
-
-
-// IfaceWithCustomBuildTagInComment is an autogenerated mock type for the IfaceWithCustomBuildTagInComment type
-type IfaceWithCustomBuildTagInComment struct {
- mock.Mock
-}
-
-type IfaceWithCustomBuildTagInComment_Expecter struct {
- mock *mock.Mock
-}
-
-func (_m *IfaceWithCustomBuildTagInComment) EXPECT() *IfaceWithCustomBuildTagInComment_Expecter {
- return &IfaceWithCustomBuildTagInComment_Expecter{mock: &_m.Mock}
-}
-
-
-
-// Custom2 provides a mock function for the type IfaceWithCustomBuildTagInComment
-func (_mock *IfaceWithCustomBuildTagInComment) Custom2() { _mock.Called()
- return
-}
-
-
-
-// IfaceWithCustomBuildTagInComment_Custom2_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Custom2'
-type IfaceWithCustomBuildTagInComment_Custom2_Call struct {
- *mock.Call
-}
-
-
-
-// Custom2 is a helper method to define mock.On call
-func (_e *IfaceWithCustomBuildTagInComment_Expecter) Custom2() *IfaceWithCustomBuildTagInComment_Custom2_Call {
- return &IfaceWithCustomBuildTagInComment_Custom2_Call{Call: _e.mock.On("Custom2", )}
-}
-
-func (_c *IfaceWithCustomBuildTagInComment_Custom2_Call) Run(run func()) *IfaceWithCustomBuildTagInComment_Custom2_Call {
- _c.Call.Run(func(args mock.Arguments) {
- run()
- })
- return _c
-}
-
-func (_c *IfaceWithCustomBuildTagInComment_Custom2_Call) Return() *IfaceWithCustomBuildTagInComment_Custom2_Call {
- _c.Call.Return()
- return _c
-}
-
-func (_c *IfaceWithCustomBuildTagInComment_Custom2_Call) RunAndReturn(run func()) *IfaceWithCustomBuildTagInComment_Custom2_Call {
- _c.Run(run)
- return _c
-}
-
-
-// Sprintf provides a mock function for the type IfaceWithCustomBuildTagInComment
-func (_mock *IfaceWithCustomBuildTagInComment) Sprintf(format string, a ...interface{}) string {
- var tmpRet mock.Arguments
- if len(a) > 0 {tmpRet = _mock.Called(format, a)
- } else {tmpRet = _mock.Called(format)
- }
- ret := tmpRet
-
- if len(ret) == 0 {
- panic("no return value specified for Sprintf")
- }
-
-
- var r0 string
- if returnFunc, ok := ret.Get(0).(func(string, ...interface{}) string); ok {
- r0 = returnFunc(format, a...)
- } else {
- r0 = ret.Get(0).(string)
- }
- return r0
-}
-
-
-
-// IfaceWithCustomBuildTagInComment_Sprintf_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Sprintf'
-type IfaceWithCustomBuildTagInComment_Sprintf_Call struct {
- *mock.Call
-}
-
-
-
-// Sprintf is a helper method to define mock.On call
-// - format
-// - a
-func (_e *IfaceWithCustomBuildTagInComment_Expecter) Sprintf(format interface{}, a ...interface{}, ) *IfaceWithCustomBuildTagInComment_Sprintf_Call {
- return &IfaceWithCustomBuildTagInComment_Sprintf_Call{Call: _e.mock.On("Sprintf",
- append([]interface{}{ format, }, a... )... )}
-}
-
-func (_c *IfaceWithCustomBuildTagInComment_Sprintf_Call) Run(run func(format string, a ...interface{})) *IfaceWithCustomBuildTagInComment_Sprintf_Call {
- _c.Call.Run(func(args mock.Arguments) {
- variadicArgs := make([]interface{}, len(args) - 1)
- for i, a := range args[1:] {
- if a != nil {
- variadicArgs[i] = a.(interface{})
- }
- }
- run(args[0].(string),variadicArgs...)
- })
- return _c
-}
-
-func (_c *IfaceWithCustomBuildTagInComment_Sprintf_Call) Return(s string) *IfaceWithCustomBuildTagInComment_Sprintf_Call {
- _c.Call.Return(s)
- return _c
-}
-
-func (_c *IfaceWithCustomBuildTagInComment_Sprintf_Call) RunAndReturn(run func(format string, a ...interface{})string) *IfaceWithCustomBuildTagInComment_Sprintf_Call {
- _c.Call.Return(run)
- return _c
-}
-
-
diff --git a/registry/method_scope.go b/registry/method_scope.go
index 8001705d..7fc3a724 100644
--- a/registry/method_scope.go
+++ b/registry/method_scope.go
@@ -26,17 +26,17 @@ type MethodScope struct {
}
func NewMethodScope(r *Registry) *MethodScope {
- visibleNames := map[string]any{}
- for key := range r.importQualifiers {
- visibleNames[key] = nil
- }
- return &MethodScope{
+ m := &MethodScope{
registry: r,
vars: []*Var{},
conflicted: map[string]bool{},
- visibleNames: visibleNames,
+ visibleNames: map[string]any{},
imports: map[string]*Package{},
}
+ for key := range r.importQualifiers {
+ m.AddName(key)
+ }
+ return m
}
func (m *MethodScope) ResolveVariableNameCollisions(ctx context.Context) {
@@ -48,7 +48,7 @@ func (m *MethodScope) ResolveVariableNameCollisions(ctx context.Context) {
varLog.Debug().Str("new-name", newName).Msg("variable was found to conflict with previously allocated name. Giving new name.")
}
v.Name = newName
- m.visibleNames[v.Name] = nil
+ m.AddName(v.Name)
}
}
@@ -65,7 +65,7 @@ func (m *MethodScope) AllocateName(prefix string) string {
suggestion = fmt.Sprintf("%s%d", prefix, i)
}
- if _, suggestionExists := m.visibleNames[suggestion]; suggestionExists {
+ if m.NameExists(suggestion) {
continue
}
break
@@ -78,41 +78,40 @@ func (m *MethodScope) AllocateName(prefix string) string {
// Variables names are generated if required and are ensured to be
// without conflict with other variables and imported packages. It also
// adds the relevant imports to the registry for each added variable.
-func (m *MethodScope) AddVar(ctx context.Context, vr *types.Var, prefix string) *Var {
- log := zerolog.Ctx(ctx).
- With().
- Str("prefix", prefix).
- Str("variable-name", vr.Name()).
- Logger()
- imports := m.populateImports(ctx, vr.Type())
-
- log.Debug().Msg("adding var")
- for key := range m.visibleNames {
- log.Debug().Str("visible-name", key).Msg("visible name")
- }
-
+func (m *MethodScope) AddVar(vr *types.Var, prefix string) *Var {
+ imports := m.populateImports(context.Background(), vr.Type())
v := Var{
vr: vr,
imports: imports,
moqPkgPath: m.moqPkgPath,
}
// The variable type is also a visible name, so add that.
- m.visibleNames[v.TypeString()] = nil
+ m.AddName(v.TypeString())
v.Name = m.AllocateName(varName(vr, prefix))
- // This suggested name is subject to change because it might come into conflict
- // with a future package import.
- log.Debug().Str("suggested-name", v.Name).Msg("suggested name for variable in method")
m.vars = append(m.vars, &v)
return &v
}
+// AddName records name as visible in the current scope. This may be useful
+// in cases where a template statically adds its own name that needs to be registered
+// with the scope to prevent future naming collisions.
+func (m *MethodScope) AddName(name string) {
+ m.visibleNames[name] = nil
+}
+
+// NameExists returns whether or not the name is currently visible in the scope.
+func (m *MethodScope) NameExists(name string) bool {
+ _, exists := m.visibleNames[name]
+ return exists
+}
+
func (m *MethodScope) addImport(ctx context.Context, pkg *types.Package, imports map[string]*Package) {
imprt := m.registry.AddImport(ctx, pkg)
imports[pkg.Path()] = imprt
m.imports[pkg.Path()] = imprt
- m.visibleNames[imprt.Qualifier()] = nil
+ m.AddName(imprt.Qualifier())
}
func (m *MethodScope) populateImportNamedType(
diff --git a/template/template_data.go b/template/template_data.go
index d4f35718..370c0444 100644
--- a/template/template_data.go
+++ b/template/template_data.go
@@ -8,6 +8,18 @@ import (
"github.com/vektra/mockery/v3/registry"
)
+type ConfigData struct {
+ ConfigDir string
+ InterfaceDir string
+ InterfaceDirRelative string
+ InterfaceFile string
+ InterfaceName string
+ Mock string
+ MockName string
+ SrcPackageName string
+ SrcPackagePath string
+}
+
// Data is the template data used to render the Moq template.
type Data struct {
Boilerplate string
@@ -16,9 +28,6 @@ type Data struct {
SrcPkgQualifier string
Imports []*registry.Package
Mocks []MockData
- StubImpl bool
- SkipEnsure bool
- WithResets bool
TemplateData map[string]any
}