-
-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Moq creates non-unique import aliases #184
Comments
@cldmstr thanks for opening this - can you please explain your proposed solution? |
Thank you very much @cldmstr for proposing a solution along with the issue! However, there is still a chance of conflict if, for example, the |
Thanks a lot for looking into this @sudo-suhas. Yes, I think your solution is definitely more complete and will solve any such problems, no matter the level. |
In one of our projects I have an, admittedly quite exotic, edge-case where we're mocking an interface from another package and the transient imports all have the same package name at the end of the path. The conflict resolve mechanism for aliases doesn't work in this case, as it only looks at 2 conflicting packages at a time.
To reproduce it requires at least 4 imports and you need to be mocking an interface from another package, so not setting unique aliases yourself.
Mocked Interface
Original Interface
The origin is that we're using an interface from the
k8s.io/client-go/kubernetes
package and want to use mocks of that interface in our tests.I put together a test case and possible solution here:
https://github.com/cldmstr/moq/tree/unique-import-aliases
The text was updated successfully, but these errors were encountered: