From 4ced14ba569b24d3747ad0371d757bf296e369fe Mon Sep 17 00:00:00 2001 From: LandonTClipp <11232769+LandonTClipp@users.noreply.github.com> Date: Mon, 18 Nov 2024 23:13:33 -0600 Subject: [PATCH] Updates --- .mockery.yaml | 17 +++- Taskfile.yml | 2 +- cmd/mockery.go | 7 ++ .../{TypesPackage.go => TypesPackage_mock.go} | 0 .../v2/pkg/fixtures/{A.go => A_mock.go} | 0 ...AsyncProducer.go => AsyncProducer_mock.go} | 0 .../pkg/fixtures/{Blank.go => Blank_mock.go} | 0 .../{ConsulLock.go => ConsulLock_mock.go} | 0 .../{EmbeddedGet.go => EmbeddedGet_mock.go} | 0 .../fixtures/{Example.go => Example_mock.go} | 0 ...c.go => ExpecterAndRolledVariadic_mock.go} | 0 .../{Expecter.go => Expecter_mock.go} | 0 .../pkg/fixtures/{Fooer.go => Fooer_mock.go} | 0 ...Collision.go => FuncArgsCollision_mock.go} | 0 ...cInterface.go => GenericInterface_mock.go} | 0 .../{GetGeneric.go => GetGeneric_mock.go} | 0 .../fixtures/{GetInt.go => GetInt_mock.go} | 0 ...go => HasConflictingNestedImports_mock.go} | 0 ...ackage.go => ImportsSameAsPackage_mock.go} | 0 ...o => InstantiatedGenericInterface_mock.go} | 0 .../{Issue766.go => Issue766_mock.go} | 0 .../{KeyManager.go => KeyManager_mock.go} | 0 .../fixtures/{MapFunc.go => MapFunc_mock.go} | 0 ...pToInterface.go => MapToInterface_mock.go} | 0 .../{MyReader.go => MyReader_mock.go} | 0 ...nValue.go => PanicOnNoReturnValue_mock.go} | 0 ...ericSelf.go => ReplaceGenericSelf_mock.go} | 0 ...placeGeneric.go => ReplaceGeneric_mock.go} | 0 .../{Requester2.go => Requester2_mock.go} | 0 .../{Requester3.go => Requester3_mock.go} | 0 .../{Requester4.go => Requester4_mock.go} | 0 ...rt.go => RequesterArgSameAsImport_mock.go} | 0 ... => RequesterArgSameAsNamedImport_mock.go} | 0 ...AsPkg.go => RequesterArgSameAsPkg_mock.go} | 0 ...questerArray.go => RequesterArray_mock.go} | 0 ...esterElided.go => RequesterElided_mock.go} | 0 ...rGenerics.go => RequesterGenerics_mock.go} | 0 ...questerIface.go => RequesterIface_mock.go} | 0 .../{RequesterNS.go => RequesterNS_mock.go} | 0 .../{RequesterPtr.go => RequesterPtr_mock.go} | 0 ...lided.go => RequesterReturnElided_mock.go} | 0 ...questerSlice.go => RequesterSlice_mock.go} | 0 ...o => RequesterVariadicOneArgument_mock.go} | 0 ...rVariadic.go => RequesterVariadic_mock.go} | 0 .../{Requester.go => Requester_mock.go} | 0 .../{SendFunc.go => SendFunc_mock.go} | 0 .../fixtures/{Sibling.go => Sibling_mock.go} | 0 ...StructWithTag.go => StructWithTag_mock.go} | 0 ...feInterface.go => UnsafeInterface_mock.go} | 0 .../fixtures/{UsesAny.go => UsesAny_mock.go} | 0 ...rPkgIface.go => UsesOtherPkgIface_mock.go} | 0 ...e.go => VariadicNoReturnInterface_mock.go} | 0 ...turnFunc.go => VariadicReturnFunc_mock.go} | 0 .../{Variadic.go => Variadic_mock.go} | 0 ... IfaceWithCustomBuildTagInComment_mock.go} | 0 ...xported.go => requesterUnexported_mock.go} | 0 pkg/config/config.go | 1 + .../example_project/mock_Stringer_test.go | 69 ---------------- pkg/fixtures/type_alias/interface.go | 7 ++ pkg/fixtures/type_alias/interface_test.go | 56 +++++++++++++ .../mock_InterfaceWithResolvedAlias_test.go | 77 ++++++++++++++++++ .../mock_InterfaceWithUnresolvedAlias_test.go | 80 +++++++++++++++++++ pkg/generator.go | 4 + pkg/outputter.go | 3 +- pkg/walker.go | 2 + 65 files changed, 253 insertions(+), 72 deletions(-) rename mocks/github.com/vektra/mockery/v2/pkg/{TypesPackage.go => TypesPackage_mock.go} (100%) rename mocks/github.com/vektra/mockery/v2/pkg/fixtures/{A.go => A_mock.go} (100%) rename mocks/github.com/vektra/mockery/v2/pkg/fixtures/{AsyncProducer.go => AsyncProducer_mock.go} (100%) rename mocks/github.com/vektra/mockery/v2/pkg/fixtures/{Blank.go => Blank_mock.go} (100%) rename mocks/github.com/vektra/mockery/v2/pkg/fixtures/{ConsulLock.go => ConsulLock_mock.go} (100%) rename mocks/github.com/vektra/mockery/v2/pkg/fixtures/{EmbeddedGet.go => EmbeddedGet_mock.go} (100%) rename mocks/github.com/vektra/mockery/v2/pkg/fixtures/{Example.go => Example_mock.go} (100%) rename mocks/github.com/vektra/mockery/v2/pkg/fixtures/{ExpecterAndRolledVariadic.go => ExpecterAndRolledVariadic_mock.go} (100%) rename mocks/github.com/vektra/mockery/v2/pkg/fixtures/{Expecter.go => Expecter_mock.go} (100%) rename mocks/github.com/vektra/mockery/v2/pkg/fixtures/{Fooer.go => Fooer_mock.go} (100%) rename mocks/github.com/vektra/mockery/v2/pkg/fixtures/{FuncArgsCollision.go => FuncArgsCollision_mock.go} (100%) rename mocks/github.com/vektra/mockery/v2/pkg/fixtures/{GenericInterface.go => GenericInterface_mock.go} (100%) rename mocks/github.com/vektra/mockery/v2/pkg/fixtures/{GetGeneric.go => GetGeneric_mock.go} (100%) rename mocks/github.com/vektra/mockery/v2/pkg/fixtures/{GetInt.go => GetInt_mock.go} (100%) rename mocks/github.com/vektra/mockery/v2/pkg/fixtures/{HasConflictingNestedImports.go => HasConflictingNestedImports_mock.go} (100%) rename mocks/github.com/vektra/mockery/v2/pkg/fixtures/{ImportsSameAsPackage.go => ImportsSameAsPackage_mock.go} (100%) rename mocks/github.com/vektra/mockery/v2/pkg/fixtures/{InstantiatedGenericInterface.go => InstantiatedGenericInterface_mock.go} (100%) rename mocks/github.com/vektra/mockery/v2/pkg/fixtures/{Issue766.go => Issue766_mock.go} (100%) rename mocks/github.com/vektra/mockery/v2/pkg/fixtures/{KeyManager.go => KeyManager_mock.go} (100%) rename mocks/github.com/vektra/mockery/v2/pkg/fixtures/{MapFunc.go => MapFunc_mock.go} (100%) rename mocks/github.com/vektra/mockery/v2/pkg/fixtures/{MapToInterface.go => MapToInterface_mock.go} (100%) rename mocks/github.com/vektra/mockery/v2/pkg/fixtures/{MyReader.go => MyReader_mock.go} (100%) rename mocks/github.com/vektra/mockery/v2/pkg/fixtures/{PanicOnNoReturnValue.go => PanicOnNoReturnValue_mock.go} (100%) rename mocks/github.com/vektra/mockery/v2/pkg/fixtures/{ReplaceGenericSelf.go => ReplaceGenericSelf_mock.go} (100%) rename mocks/github.com/vektra/mockery/v2/pkg/fixtures/{ReplaceGeneric.go => ReplaceGeneric_mock.go} (100%) rename mocks/github.com/vektra/mockery/v2/pkg/fixtures/{Requester2.go => Requester2_mock.go} (100%) rename mocks/github.com/vektra/mockery/v2/pkg/fixtures/{Requester3.go => Requester3_mock.go} (100%) rename mocks/github.com/vektra/mockery/v2/pkg/fixtures/{Requester4.go => Requester4_mock.go} (100%) rename mocks/github.com/vektra/mockery/v2/pkg/fixtures/{RequesterArgSameAsImport.go => RequesterArgSameAsImport_mock.go} (100%) rename mocks/github.com/vektra/mockery/v2/pkg/fixtures/{RequesterArgSameAsNamedImport.go => RequesterArgSameAsNamedImport_mock.go} (100%) rename mocks/github.com/vektra/mockery/v2/pkg/fixtures/{RequesterArgSameAsPkg.go => RequesterArgSameAsPkg_mock.go} (100%) rename mocks/github.com/vektra/mockery/v2/pkg/fixtures/{RequesterArray.go => RequesterArray_mock.go} (100%) rename mocks/github.com/vektra/mockery/v2/pkg/fixtures/{RequesterElided.go => RequesterElided_mock.go} (100%) rename mocks/github.com/vektra/mockery/v2/pkg/fixtures/{RequesterGenerics.go => RequesterGenerics_mock.go} (100%) rename mocks/github.com/vektra/mockery/v2/pkg/fixtures/{RequesterIface.go => RequesterIface_mock.go} (100%) rename mocks/github.com/vektra/mockery/v2/pkg/fixtures/{RequesterNS.go => RequesterNS_mock.go} (100%) rename mocks/github.com/vektra/mockery/v2/pkg/fixtures/{RequesterPtr.go => RequesterPtr_mock.go} (100%) rename mocks/github.com/vektra/mockery/v2/pkg/fixtures/{RequesterReturnElided.go => RequesterReturnElided_mock.go} (100%) rename mocks/github.com/vektra/mockery/v2/pkg/fixtures/{RequesterSlice.go => RequesterSlice_mock.go} (100%) rename mocks/github.com/vektra/mockery/v2/pkg/fixtures/{RequesterVariadicOneArgument.go => RequesterVariadicOneArgument_mock.go} (100%) rename mocks/github.com/vektra/mockery/v2/pkg/fixtures/{RequesterVariadic.go => RequesterVariadic_mock.go} (100%) rename mocks/github.com/vektra/mockery/v2/pkg/fixtures/{Requester.go => Requester_mock.go} (100%) rename mocks/github.com/vektra/mockery/v2/pkg/fixtures/{SendFunc.go => SendFunc_mock.go} (100%) rename mocks/github.com/vektra/mockery/v2/pkg/fixtures/{Sibling.go => Sibling_mock.go} (100%) rename mocks/github.com/vektra/mockery/v2/pkg/fixtures/{StructWithTag.go => StructWithTag_mock.go} (100%) rename mocks/github.com/vektra/mockery/v2/pkg/fixtures/{UnsafeInterface.go => UnsafeInterface_mock.go} (100%) rename mocks/github.com/vektra/mockery/v2/pkg/fixtures/{UsesAny.go => UsesAny_mock.go} (100%) rename mocks/github.com/vektra/mockery/v2/pkg/fixtures/{UsesOtherPkgIface.go => UsesOtherPkgIface_mock.go} (100%) rename mocks/github.com/vektra/mockery/v2/pkg/fixtures/{VariadicNoReturnInterface.go => VariadicNoReturnInterface_mock.go} (100%) rename mocks/github.com/vektra/mockery/v2/pkg/fixtures/{VariadicReturnFunc.go => VariadicReturnFunc_mock.go} (100%) rename mocks/github.com/vektra/mockery/v2/pkg/fixtures/{Variadic.go => Variadic_mock.go} (100%) rename mocks/github.com/vektra/mockery/v2/pkg/fixtures/buildtag/comment/{IfaceWithCustomBuildTagInComment.go => IfaceWithCustomBuildTagInComment_mock.go} (100%) rename mocks/github.com/vektra/mockery/v2/pkg/fixtures/{requesterUnexported.go => requesterUnexported_mock.go} (100%) delete mode 100644 pkg/fixtures/example_project/mock_Stringer_test.go create mode 100644 pkg/fixtures/type_alias/interface.go create mode 100644 pkg/fixtures/type_alias/interface_test.go create mode 100644 pkg/fixtures/type_alias/mock_InterfaceWithResolvedAlias_test.go create mode 100644 pkg/fixtures/type_alias/mock_InterfaceWithUnresolvedAlias_test.go diff --git a/.mockery.yaml b/.mockery.yaml index c5a68623..c90163a0 100644 --- a/.mockery.yaml +++ b/.mockery.yaml @@ -2,7 +2,7 @@ quiet: False disable-version-string: True with-expecter: True mockname: "{{.InterfaceName}}" -filename: "{{.MockName}}.go" +filename: "{{.MockName}}_mock.go" outpkg: mocks tags: "custom2" issue-845-fix: True @@ -94,3 +94,18 @@ packages: mockname: WithoutFix - issue-845-fix: True mockname: WithFix + github.com/vektra/mockery/v2/pkg/fixtures/type_alias: + config: + all: True + dir: "{{.InterfaceDir}}" + filename: "mock_{{.MockName}}_test.go" + outpkg: "fuck" + inpackage: True + interfaces: + Interface1: + configs: + - resolve-type-alias: False + mockname: InterfaceWithUnresolvedAlias + - resolve-type-alias: True + mockname: InterfaceWithResolvedAlias + diff --git a/Taskfile.yml b/Taskfile.yml index 8c6ff4c0..315fa298 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -21,7 +21,7 @@ tasks: mocks.remove: desc: remove all mock files cmds: - - find . -name '*_mock.go' | xargs -r rm + - find . -name '*_mock.go' -o -name 'mock_*_test.go' | xargs -r rm - rm -rf mocks/ mocks.generate: diff --git a/cmd/mockery.go b/cmd/mockery.go index ac0b7737..792c4b3e 100644 --- a/cmd/mockery.go +++ b/cmd/mockery.go @@ -231,6 +231,12 @@ func (r *RootApp) Run() error { } if len(configuredPackages) != 0 { r.Config.LogUnsupportedPackagesConfig(ctx) + if !r.Config.Issue845Fix { + warnDeprecated( + ctx, + "issue-845-fix must be set to True to remove this warning. Visit the link for more details." + ) + } configuredPackages, err := r.Config.GetPackages(ctx) if err != nil { @@ -377,6 +383,7 @@ func (r *RootApp) Run() error { UnrollVariadic: r.Config.UnrollVariadic, WithExpecter: r.Config.WithExpecter, ReplaceType: r.Config.ReplaceType, + ResolveTypeAlias: r.Config.ResolveTypeAlias, }, osp, r.Config.DryRun) generated := walker.Walk(ctx, visitor) diff --git a/mocks/github.com/vektra/mockery/v2/pkg/TypesPackage.go b/mocks/github.com/vektra/mockery/v2/pkg/TypesPackage_mock.go similarity index 100% rename from mocks/github.com/vektra/mockery/v2/pkg/TypesPackage.go rename to mocks/github.com/vektra/mockery/v2/pkg/TypesPackage_mock.go diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/A.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/A_mock.go similarity index 100% rename from mocks/github.com/vektra/mockery/v2/pkg/fixtures/A.go rename to mocks/github.com/vektra/mockery/v2/pkg/fixtures/A_mock.go diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/AsyncProducer.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/AsyncProducer_mock.go similarity index 100% rename from mocks/github.com/vektra/mockery/v2/pkg/fixtures/AsyncProducer.go rename to mocks/github.com/vektra/mockery/v2/pkg/fixtures/AsyncProducer_mock.go diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/Blank.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/Blank_mock.go similarity index 100% rename from mocks/github.com/vektra/mockery/v2/pkg/fixtures/Blank.go rename to mocks/github.com/vektra/mockery/v2/pkg/fixtures/Blank_mock.go diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/ConsulLock.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/ConsulLock_mock.go similarity index 100% rename from mocks/github.com/vektra/mockery/v2/pkg/fixtures/ConsulLock.go rename to mocks/github.com/vektra/mockery/v2/pkg/fixtures/ConsulLock_mock.go diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/EmbeddedGet.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/EmbeddedGet_mock.go similarity index 100% rename from mocks/github.com/vektra/mockery/v2/pkg/fixtures/EmbeddedGet.go rename to mocks/github.com/vektra/mockery/v2/pkg/fixtures/EmbeddedGet_mock.go diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/Example.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/Example_mock.go similarity index 100% rename from mocks/github.com/vektra/mockery/v2/pkg/fixtures/Example.go rename to mocks/github.com/vektra/mockery/v2/pkg/fixtures/Example_mock.go diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/ExpecterAndRolledVariadic.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/ExpecterAndRolledVariadic_mock.go similarity index 100% rename from mocks/github.com/vektra/mockery/v2/pkg/fixtures/ExpecterAndRolledVariadic.go rename to mocks/github.com/vektra/mockery/v2/pkg/fixtures/ExpecterAndRolledVariadic_mock.go diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/Expecter.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/Expecter_mock.go similarity index 100% rename from mocks/github.com/vektra/mockery/v2/pkg/fixtures/Expecter.go rename to mocks/github.com/vektra/mockery/v2/pkg/fixtures/Expecter_mock.go diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/Fooer.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/Fooer_mock.go similarity index 100% rename from mocks/github.com/vektra/mockery/v2/pkg/fixtures/Fooer.go rename to mocks/github.com/vektra/mockery/v2/pkg/fixtures/Fooer_mock.go diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/FuncArgsCollision.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/FuncArgsCollision_mock.go similarity index 100% rename from mocks/github.com/vektra/mockery/v2/pkg/fixtures/FuncArgsCollision.go rename to mocks/github.com/vektra/mockery/v2/pkg/fixtures/FuncArgsCollision_mock.go diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/GenericInterface.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/GenericInterface_mock.go similarity index 100% rename from mocks/github.com/vektra/mockery/v2/pkg/fixtures/GenericInterface.go rename to mocks/github.com/vektra/mockery/v2/pkg/fixtures/GenericInterface_mock.go diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/GetGeneric.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/GetGeneric_mock.go similarity index 100% rename from mocks/github.com/vektra/mockery/v2/pkg/fixtures/GetGeneric.go rename to mocks/github.com/vektra/mockery/v2/pkg/fixtures/GetGeneric_mock.go diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/GetInt.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/GetInt_mock.go similarity index 100% rename from mocks/github.com/vektra/mockery/v2/pkg/fixtures/GetInt.go rename to mocks/github.com/vektra/mockery/v2/pkg/fixtures/GetInt_mock.go diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/HasConflictingNestedImports.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/HasConflictingNestedImports_mock.go similarity index 100% rename from mocks/github.com/vektra/mockery/v2/pkg/fixtures/HasConflictingNestedImports.go rename to mocks/github.com/vektra/mockery/v2/pkg/fixtures/HasConflictingNestedImports_mock.go diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/ImportsSameAsPackage.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/ImportsSameAsPackage_mock.go similarity index 100% rename from mocks/github.com/vektra/mockery/v2/pkg/fixtures/ImportsSameAsPackage.go rename to mocks/github.com/vektra/mockery/v2/pkg/fixtures/ImportsSameAsPackage_mock.go diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/InstantiatedGenericInterface.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/InstantiatedGenericInterface_mock.go similarity index 100% rename from mocks/github.com/vektra/mockery/v2/pkg/fixtures/InstantiatedGenericInterface.go rename to mocks/github.com/vektra/mockery/v2/pkg/fixtures/InstantiatedGenericInterface_mock.go diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/Issue766.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/Issue766_mock.go similarity index 100% rename from mocks/github.com/vektra/mockery/v2/pkg/fixtures/Issue766.go rename to mocks/github.com/vektra/mockery/v2/pkg/fixtures/Issue766_mock.go diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/KeyManager.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/KeyManager_mock.go similarity index 100% rename from mocks/github.com/vektra/mockery/v2/pkg/fixtures/KeyManager.go rename to mocks/github.com/vektra/mockery/v2/pkg/fixtures/KeyManager_mock.go diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/MapFunc.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/MapFunc_mock.go similarity index 100% rename from mocks/github.com/vektra/mockery/v2/pkg/fixtures/MapFunc.go rename to mocks/github.com/vektra/mockery/v2/pkg/fixtures/MapFunc_mock.go diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/MapToInterface.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/MapToInterface_mock.go similarity index 100% rename from mocks/github.com/vektra/mockery/v2/pkg/fixtures/MapToInterface.go rename to mocks/github.com/vektra/mockery/v2/pkg/fixtures/MapToInterface_mock.go diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/MyReader.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/MyReader_mock.go similarity index 100% rename from mocks/github.com/vektra/mockery/v2/pkg/fixtures/MyReader.go rename to mocks/github.com/vektra/mockery/v2/pkg/fixtures/MyReader_mock.go diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/PanicOnNoReturnValue.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/PanicOnNoReturnValue_mock.go similarity index 100% rename from mocks/github.com/vektra/mockery/v2/pkg/fixtures/PanicOnNoReturnValue.go rename to mocks/github.com/vektra/mockery/v2/pkg/fixtures/PanicOnNoReturnValue_mock.go diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/ReplaceGenericSelf.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/ReplaceGenericSelf_mock.go similarity index 100% rename from mocks/github.com/vektra/mockery/v2/pkg/fixtures/ReplaceGenericSelf.go rename to mocks/github.com/vektra/mockery/v2/pkg/fixtures/ReplaceGenericSelf_mock.go diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/ReplaceGeneric.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/ReplaceGeneric_mock.go similarity index 100% rename from mocks/github.com/vektra/mockery/v2/pkg/fixtures/ReplaceGeneric.go rename to mocks/github.com/vektra/mockery/v2/pkg/fixtures/ReplaceGeneric_mock.go diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/Requester2.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/Requester2_mock.go similarity index 100% rename from mocks/github.com/vektra/mockery/v2/pkg/fixtures/Requester2.go rename to mocks/github.com/vektra/mockery/v2/pkg/fixtures/Requester2_mock.go diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/Requester3.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/Requester3_mock.go similarity index 100% rename from mocks/github.com/vektra/mockery/v2/pkg/fixtures/Requester3.go rename to mocks/github.com/vektra/mockery/v2/pkg/fixtures/Requester3_mock.go diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/Requester4.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/Requester4_mock.go similarity index 100% rename from mocks/github.com/vektra/mockery/v2/pkg/fixtures/Requester4.go rename to mocks/github.com/vektra/mockery/v2/pkg/fixtures/Requester4_mock.go diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsImport.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsImport_mock.go similarity index 100% rename from mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsImport.go rename to mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsImport_mock.go diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsNamedImport.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsNamedImport_mock.go similarity index 100% rename from mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsNamedImport.go rename to mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsNamedImport_mock.go diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsPkg.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsPkg_mock.go similarity index 100% rename from mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsPkg.go rename to mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsPkg_mock.go diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArray.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArray_mock.go similarity index 100% rename from mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArray.go rename to mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArray_mock.go diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterElided.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterElided_mock.go similarity index 100% rename from mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterElided.go rename to mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterElided_mock.go diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterGenerics.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterGenerics_mock.go similarity index 100% rename from mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterGenerics.go rename to mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterGenerics_mock.go diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterIface.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterIface_mock.go similarity index 100% rename from mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterIface.go rename to mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterIface_mock.go diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterNS.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterNS_mock.go similarity index 100% rename from mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterNS.go rename to mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterNS_mock.go diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterPtr.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterPtr_mock.go similarity index 100% rename from mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterPtr.go rename to mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterPtr_mock.go diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterReturnElided.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterReturnElided_mock.go similarity index 100% rename from mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterReturnElided.go rename to mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterReturnElided_mock.go diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterSlice.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterSlice_mock.go similarity index 100% rename from mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterSlice.go rename to mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterSlice_mock.go diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterVariadicOneArgument.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterVariadicOneArgument_mock.go similarity index 100% rename from mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterVariadicOneArgument.go rename to mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterVariadicOneArgument_mock.go diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterVariadic.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterVariadic_mock.go similarity index 100% rename from mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterVariadic.go rename to mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterVariadic_mock.go diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/Requester.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/Requester_mock.go similarity index 100% rename from mocks/github.com/vektra/mockery/v2/pkg/fixtures/Requester.go rename to mocks/github.com/vektra/mockery/v2/pkg/fixtures/Requester_mock.go diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/SendFunc.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/SendFunc_mock.go similarity index 100% rename from mocks/github.com/vektra/mockery/v2/pkg/fixtures/SendFunc.go rename to mocks/github.com/vektra/mockery/v2/pkg/fixtures/SendFunc_mock.go diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/Sibling.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/Sibling_mock.go similarity index 100% rename from mocks/github.com/vektra/mockery/v2/pkg/fixtures/Sibling.go rename to mocks/github.com/vektra/mockery/v2/pkg/fixtures/Sibling_mock.go diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/StructWithTag.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/StructWithTag_mock.go similarity index 100% rename from mocks/github.com/vektra/mockery/v2/pkg/fixtures/StructWithTag.go rename to mocks/github.com/vektra/mockery/v2/pkg/fixtures/StructWithTag_mock.go diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/UnsafeInterface.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/UnsafeInterface_mock.go similarity index 100% rename from mocks/github.com/vektra/mockery/v2/pkg/fixtures/UnsafeInterface.go rename to mocks/github.com/vektra/mockery/v2/pkg/fixtures/UnsafeInterface_mock.go diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/UsesAny.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/UsesAny_mock.go similarity index 100% rename from mocks/github.com/vektra/mockery/v2/pkg/fixtures/UsesAny.go rename to mocks/github.com/vektra/mockery/v2/pkg/fixtures/UsesAny_mock.go diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/UsesOtherPkgIface.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/UsesOtherPkgIface_mock.go similarity index 100% rename from mocks/github.com/vektra/mockery/v2/pkg/fixtures/UsesOtherPkgIface.go rename to mocks/github.com/vektra/mockery/v2/pkg/fixtures/UsesOtherPkgIface_mock.go diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/VariadicNoReturnInterface.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/VariadicNoReturnInterface_mock.go similarity index 100% rename from mocks/github.com/vektra/mockery/v2/pkg/fixtures/VariadicNoReturnInterface.go rename to mocks/github.com/vektra/mockery/v2/pkg/fixtures/VariadicNoReturnInterface_mock.go diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/VariadicReturnFunc.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/VariadicReturnFunc_mock.go similarity index 100% rename from mocks/github.com/vektra/mockery/v2/pkg/fixtures/VariadicReturnFunc.go rename to mocks/github.com/vektra/mockery/v2/pkg/fixtures/VariadicReturnFunc_mock.go diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/Variadic.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/Variadic_mock.go similarity index 100% rename from mocks/github.com/vektra/mockery/v2/pkg/fixtures/Variadic.go rename to mocks/github.com/vektra/mockery/v2/pkg/fixtures/Variadic_mock.go diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/buildtag/comment/IfaceWithCustomBuildTagInComment.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/buildtag/comment/IfaceWithCustomBuildTagInComment_mock.go similarity index 100% rename from mocks/github.com/vektra/mockery/v2/pkg/fixtures/buildtag/comment/IfaceWithCustomBuildTagInComment.go rename to mocks/github.com/vektra/mockery/v2/pkg/fixtures/buildtag/comment/IfaceWithCustomBuildTagInComment_mock.go diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/requesterUnexported.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/requesterUnexported_mock.go similarity index 100% rename from mocks/github.com/vektra/mockery/v2/pkg/fixtures/requesterUnexported.go rename to mocks/github.com/vektra/mockery/v2/pkg/fixtures/requesterUnexported_mock.go diff --git a/pkg/config/config.go b/pkg/config/config.go index 25ad1e13..97e085a1 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -52,6 +52,7 @@ type Config struct { Issue845Fix bool `mapstructure:"issue-845-fix"` IncludeAutoGenerated bool `mapstructure:"include-auto-generated"` IncludeRegex string `mapstructure:"include-regex"` + Issue845Fix bool `mapstructure:"issue-845-fix"` KeepTree bool `mapstructure:"keeptree"` LogLevel string `mapstructure:"log-level"` MockBuildTags string `mapstructure:"mock-build-tags"` diff --git a/pkg/fixtures/example_project/mock_Stringer_test.go b/pkg/fixtures/example_project/mock_Stringer_test.go deleted file mode 100644 index 4521254d..00000000 --- a/pkg/fixtures/example_project/mock_Stringer_test.go +++ /dev/null @@ -1,69 +0,0 @@ -// Code generated by mockery. DO NOT EDIT. - -package example_project - -import mock "github.com/stretchr/testify/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 with given fields: -func (_m *MockStringer) String() string { - ret := _m.Called() - - var r0 string - if rf, ok := ret.Get(0).(func() string); ok { - r0 = rf() - } 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(_a0 string) *MockStringer_String_Call { - _c.Call.Return(_a0) - return _c -} - -type mockConstructorTestingTNewMockStringer interface { - mock.TestingT - Cleanup(func()) -} - -// 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. -func NewMockStringer(t mockConstructorTestingTNewMockStringer) *MockStringer { - mock := &MockStringer{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/pkg/fixtures/type_alias/interface.go b/pkg/fixtures/type_alias/interface.go new file mode 100644 index 00000000..95b16766 --- /dev/null +++ b/pkg/fixtures/type_alias/interface.go @@ -0,0 +1,7 @@ +package type_alias + +type Type = int + +type Interface1 interface { + Foo() Type +} diff --git a/pkg/fixtures/type_alias/interface_test.go b/pkg/fixtures/type_alias/interface_test.go new file mode 100644 index 00000000..0c771f95 --- /dev/null +++ b/pkg/fixtures/type_alias/interface_test.go @@ -0,0 +1,56 @@ +package type_alias_test + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + "github.com/vektra/mockery/v2/pkg" + "golang.org/x/tools/go/packages" +) + +func TestTypeAliasResolved(t *testing.T) { + parser := pkg.NewParser([]string{}) + require.NoError(t, parser.ParsePackages(context.Background(), []string{"github.com/vektra/mockery/v2/fixtures/type_alias"})) + var config packages.Config + config.Mode = packages.NeedTypes | + packages.NeedTypesSizes | + packages.NeedSyntax | + packages.NeedTypesInfo | + packages.NeedImports | + packages.NeedName | + packages.NeedFiles | + packages.NeedCompiledGoFiles + config.Tests = true + packageList, err := packages.Load(&config, "github.com/vektra/mockery/v2/pkg/fixtures/type_alias") + require.NoError(t, err) + require.Equal(t, 3, len(packageList)) + + //var pkg *packages.Package + + for _, pkgElem := range packageList { + t.Log(pkgElem.ID) + } + + //pkg := packageList[0] + //for _, file := range pkg.Syntax { + // t.Log("FOUND FILE") + // t.Log(file.Name.Name) + // for _, decl := range file.Decls { + // t.Logf("%v", decl) + // } + //} + t.Fail() + +} + +//func TestTypeAliasUnResolved(t *testing.T) { +// expectedReturn := Type(1) +// mockInterface := NewInterfaceWithUnresolvedAlias(t) +// mockInterface.EXPECT().Foo().Return(expectedReturn) +// +// actualReturn := mockInterface.Foo() +// assert.Equal(t, "foo", reflect.TypeOf(actualReturn).String()) +// assert.Equal(t, expectedReturn, actualReturn) +// +//} diff --git a/pkg/fixtures/type_alias/mock_InterfaceWithResolvedAlias_test.go b/pkg/fixtures/type_alias/mock_InterfaceWithResolvedAlias_test.go new file mode 100644 index 00000000..cc77c9ad --- /dev/null +++ b/pkg/fixtures/type_alias/mock_InterfaceWithResolvedAlias_test.go @@ -0,0 +1,77 @@ +// Code generated by mockery. DO NOT EDIT. + +package fuck + +import mock "github.com/stretchr/testify/mock" + +// InterfaceWithResolvedAlias is an autogenerated mock type for the Interface1 type +type InterfaceWithResolvedAlias struct { + mock.Mock +} + +type InterfaceWithResolvedAlias_Expecter struct { + mock *mock.Mock +} + +func (_m *InterfaceWithResolvedAlias) EXPECT() *InterfaceWithResolvedAlias_Expecter { + return &InterfaceWithResolvedAlias_Expecter{mock: &_m.Mock} +} + +// Foo provides a mock function with given fields: +func (_m *InterfaceWithResolvedAlias) Foo() int { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Foo") + } + + var r0 int + if rf, ok := ret.Get(0).(func() int); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(int) + } + + return r0 +} + +// InterfaceWithResolvedAlias_Foo_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Foo' +type InterfaceWithResolvedAlias_Foo_Call struct { + *mock.Call +} + +// Foo is a helper method to define mock.On call +func (_e *InterfaceWithResolvedAlias_Expecter) Foo() *InterfaceWithResolvedAlias_Foo_Call { + return &InterfaceWithResolvedAlias_Foo_Call{Call: _e.mock.On("Foo")} +} + +func (_c *InterfaceWithResolvedAlias_Foo_Call) Run(run func()) *InterfaceWithResolvedAlias_Foo_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *InterfaceWithResolvedAlias_Foo_Call) Return(_a0 int) *InterfaceWithResolvedAlias_Foo_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *InterfaceWithResolvedAlias_Foo_Call) RunAndReturn(run func() int) *InterfaceWithResolvedAlias_Foo_Call { + _c.Call.Return(run) + return _c +} + +// NewInterfaceWithResolvedAlias creates a new instance of InterfaceWithResolvedAlias. 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 NewInterfaceWithResolvedAlias(t interface { + mock.TestingT + Cleanup(func()) +}) *InterfaceWithResolvedAlias { + mock := &InterfaceWithResolvedAlias{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/fixtures/type_alias/mock_InterfaceWithUnresolvedAlias_test.go b/pkg/fixtures/type_alias/mock_InterfaceWithUnresolvedAlias_test.go new file mode 100644 index 00000000..cba74fe6 --- /dev/null +++ b/pkg/fixtures/type_alias/mock_InterfaceWithUnresolvedAlias_test.go @@ -0,0 +1,80 @@ +// Code generated by mockery. DO NOT EDIT. + +package fuck + +import ( + mock "github.com/stretchr/testify/mock" + type_alias "github.com/vektra/mockery/v2/pkg/fixtures/type_alias" +) + +// InterfaceWithUnresolvedAlias is an autogenerated mock type for the Interface1 type +type InterfaceWithUnresolvedAlias struct { + mock.Mock +} + +type InterfaceWithUnresolvedAlias_Expecter struct { + mock *mock.Mock +} + +func (_m *InterfaceWithUnresolvedAlias) EXPECT() *InterfaceWithUnresolvedAlias_Expecter { + return &InterfaceWithUnresolvedAlias_Expecter{mock: &_m.Mock} +} + +// Foo provides a mock function with given fields: +func (_m *InterfaceWithUnresolvedAlias) Foo() type_alias.Type { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Foo") + } + + var r0 type_alias.Type + if rf, ok := ret.Get(0).(func() type_alias.Type); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(type_alias.Type) + } + + return r0 +} + +// InterfaceWithUnresolvedAlias_Foo_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Foo' +type InterfaceWithUnresolvedAlias_Foo_Call struct { + *mock.Call +} + +// Foo is a helper method to define mock.On call +func (_e *InterfaceWithUnresolvedAlias_Expecter) Foo() *InterfaceWithUnresolvedAlias_Foo_Call { + return &InterfaceWithUnresolvedAlias_Foo_Call{Call: _e.mock.On("Foo")} +} + +func (_c *InterfaceWithUnresolvedAlias_Foo_Call) Run(run func()) *InterfaceWithUnresolvedAlias_Foo_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *InterfaceWithUnresolvedAlias_Foo_Call) Return(_a0 type_alias.Type) *InterfaceWithUnresolvedAlias_Foo_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *InterfaceWithUnresolvedAlias_Foo_Call) RunAndReturn(run func() type_alias.Type) *InterfaceWithUnresolvedAlias_Foo_Call { + _c.Call.Return(run) + return _c +} + +// NewInterfaceWithUnresolvedAlias creates a new instance of InterfaceWithUnresolvedAlias. 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 NewInterfaceWithUnresolvedAlias(t interface { + mock.TestingT + Cleanup(func()) +}) *InterfaceWithUnresolvedAlias { + mock := &InterfaceWithUnresolvedAlias{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/generator.go b/pkg/generator.go index 5024e7c9..b3b3ad38 100644 --- a/pkg/generator.go +++ b/pkg/generator.go @@ -533,13 +533,17 @@ func (g *Generator) renderNamedType(ctx context.Context, t interface { } func (g *Generator) renderType(ctx context.Context, typ types.Type) string { + log := zerolog.Ctx(ctx) switch t := typ.(type) { case *types.Named: return g.renderNamedType(ctx, t) case *types.Alias: + log.Debug().Msg("found type alias") if g.config.ResolveTypeAlias { + log.Debug().Msg("resolving type alias to underlying type") return g.renderType(ctx, t.Underlying()) } + log.Debug().Msg("not resolving type alias to underlying type") return g.renderNamedType(ctx, t) case *types.TypeParam: if t.Constraint() != nil { diff --git a/pkg/outputter.go b/pkg/outputter.go index e3c4d978..75df24f6 100644 --- a/pkg/outputter.go +++ b/pkg/outputter.go @@ -342,8 +342,9 @@ func (m *Outputter) Generate(ctx context.Context, iface *Interface) error { UnrollVariadic: interfaceConfig.UnrollVariadic, WithExpecter: interfaceConfig.WithExpecter, ReplaceType: interfaceConfig.ReplaceType, + ResolveTypeAlias: interfaceConfig.ResolveTypeAlias, } - generator := NewGenerator(ctx, g, iface, "") + generator := NewGenerator(ctx, g, iface, interfaceConfig.Outpkg) log.Debug().Msg("generating mock in-memory") if err := generator.GenerateAll(ctx); err != nil { diff --git a/pkg/walker.go b/pkg/walker.go index 6d290efd..75e1e67f 100644 --- a/pkg/walker.go +++ b/pkg/walker.go @@ -128,6 +128,7 @@ type GeneratorVisitorConfig struct { UnrollVariadic bool WithExpecter bool ReplaceType []string + ResolveTypeAlias bool } type GeneratorVisitor struct { @@ -189,6 +190,7 @@ func (v *GeneratorVisitor) VisitWalk(ctx context.Context, iface *Interface) erro UnrollVariadic: v.config.UnrollVariadic, WithExpecter: v.config.WithExpecter, ReplaceType: v.config.ReplaceType, + ResolveTypeAlias: v.config.ResolveTypeAlias, } gen := NewGenerator(ctx, generatorConfig, iface, "")