-
-
Notifications
You must be signed in to change notification settings - Fork 128
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
moq generates mocks with internal package imports #153
Comments
The problem is around adding the import for a type alias - googleapis/google-cloud-go@ I have added a test case for the same in #155. For some reason, while parsing the interface method's parameters, the type information has the package as the original package instead of the one where it was aliased: As it happens, this issue affects github.com/vektra/mockery as well:
|
has there been any progress with this issue? I'm experiencing the same problem with imports |
I had tried asking for help on Gophers slack as well but I was not able to use the suggestions to arrive at a solution for the problem of type alias information - https://gophers.slack.com/archives/C0VPK4Z5E/p1629540208130200 |
I did ask on Slack as well and I have been pointed to an older discussion about the same topic as well as this issue on golang/mock#244. As far as I can tell, there is no issue on the Go issue tracker so I am not sure if there is already general awareness of this issue. Currently it looks like the only way to solve this would be to change the processing of moq such that it primarily processes ast exressions and the resolves these to types (see the above linked discussion). |
Very late to the game but hit this error and I have a problem that this does not solve. I have multiple packages that mockery maps down to a single internal package and I cannot use the mockery follows packages A, B, C to internal package Z The package that causes this is not mine and I cannot fix it so seem unable to use mockery to mock my interface. |
In some situations, moq generates mocks that try to import internal 3rd party packages. Minimal example below.
example.go
Here pubsub_api is an explicit alias to the public package.
Generate mock:
example_mock.go
But the mock imports the internal pubsub package instead. I couldn't find any way to prevent it.
go version go1.15.6 linux/amd64
moq version: v0.2.3
The text was updated successfully, but these errors were encountered: