Open FournyP opened 2 weeks ago
Here is my .mockery.yaml
config :
with-expecter: true
all: true
filename: "mock-{{ .InterfaceName | kebabcase }}.go"
outpkg: mock{{.PackageName}}
mockname: "{{.InterfaceName}}"
dir: tests/mocks/{{trimPrefix .InterfaceDirRelative "pkg/"}}
packages:
packageA:
config:
recursive: true
Hmm that's an interesting use case I have not thought of (generic interface with an instantiated type assigned to a different type name). It should work but I'm not sure what mockery thinks of this. Can you run with mockery --log-level debug | grep SendEmailVerificationUseCaseInterface
and see what mockery does with it?
Hi @LandonTClipp,
I got logs for ResponseLessUseCase
but not at all for SendEmailVerificationUseCaseInterface
If mockery did not print anything then something has gone wrong during its discovery phase of top-level interface definitions. I'll see if I can tinker with it.
Well this is hilarious. The Go AST considers this to be an index expression: *ast.IndexExpr
. Mockery does not see SendEmailVerificationUseCaseInterface
as an interface type because of this. I can successfully induce mockery to generate a mock for it by telling it to include *ast.IndexExpr
the list of types it generates mocks for (currently only interfaces and functions), but I'm not entirely sure on the implications of this. I need to think about it.
There's three ways we could resolve this:
*ast.IndexExpr
. This is highly risky as I'm unsure the ways in which this might break.
Description
Hi, I wanted to write some mock for my interface :
But only the mock for
ResponseLessUseCase
was created, maybe I miss something ?Mockery Version
v2.43.2
Golang Version
v1.22.3
Installation Method
Steps to Reproduce
Expected Behavior
A mock for the interface that inherit the generic one
Actual Behavior
Only the mock of the generic interface