-
Notifications
You must be signed in to change notification settings - Fork 416
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
v3: moq template, referring to interfaces in other packages. #882
Comments
This is certainly supported if I'm understanding you correctly. You can generate mocks for any package and store them just about anywhere. For example lets's say you have a project at packages:
github.com/user/repo/subpkg1:
config:
all: True
# Store them in the location of subpkg2
dir: "./subpkg2/"
filename: "mocks_subpkg1.go"
# generate mocks from subpkg2 as usual
github.com/user/repo/subpkg2:
config:
all: True Is that what you're asking for? |
I tried your suggestion, however, I am not able to override the package name:
Errors with:
|
When I replaced |
I think I see what's happening. The reason isn't entirely interesting but the gist is that for |
https://github.com/vektra/mockery/releases/tag/v3.0.0-alpha.15 should fix your issue. Just note that mockery will (expectedly) throw an error if the mocks you've placed in a particular file have been configured with different pkgnames. A file can only have one pkgname. |
It works. |
Description
Currently one of my workflows involve generating interfaces that belong to other packages as in:
Mockery Version
v3.0.0-alpha.12
aka365b8ebb425518810e9327b7356407ac415edd96
Go Version
go1.23
Installation Method
Steps to Reproduce
I can't reproduce in any steps because it doesn't seem to be supported.
Expected Behavior
Have a way to declare an interface from one package but store the result into another.
Actual Behavior
Behavior not available.
The text was updated successfully, but these errors were encountered: