-
Notifications
You must be signed in to change notification settings - Fork 426
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
Findings while trying v3 for matryer/moq style mocks #935
Comments
One more thing, I just saw, that for |
Thanks for taking a look into v3, it's very helpful for me to hear from users of moq. Regarding:
I'm curious to know if there is a practical reason why this is an issue? This is pretty much expected, as mockery will dynamically decide whether or not to use an alias for an import, which is essentially just a function of what other names are visible in the file-global scope. |
Go 1.24 was required because of the introduction of generic type aliases, so we need an updated toolchain to support parsing this. If this existing in the toolchain is an issue, there might be a more targeted way we can go about this. We need an updated parser (from |
As far as I can tell until now, I have not yet hit a case, where this became an issue, so I mainly raised this because of the additional changed lines, this caused in the diff of the PR, where I would have wished, that the changes are minimal if import (
someapi "github.com/some/api"
otherapi "github.com/other/api"
)
type TheInterface interface{
Method(some someapi.Thing, other otherapi.OtherThing)
} In this case, omitting the aliases in the generated code would cause invalid code, since both imported packages are named |
Ok, I see. I think the issue is caused by us using We do not have this issue with |
Findings:
template
ismatryer
, but the documentation does mentionmoq
.If this is not the case, regenerate this file with moq.
, I think this should be changed toIf this is not the case, regenerate this file with mockery.
. Location in the template: https://github.com/vektra/mockery/blob/v3/internal/mock_matryer.templ#L27moq
, if the mocked interface has used a type from an other package, that has been imported using an alias, this alias has also been used in the generated mock. This is no longer the case with mockery.The text was updated successfully, but these errors were encountered: