-
Notifications
You must be signed in to change notification settings - Fork 28
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
Allow creating mocks for *_test package interfaces #88
Comments
@jpopadak Trying to understand how you can call If All that being said, I guess the code could be changed, that it makes it possible to include |
@petergtz This is possible. There are many locations in the Go code base that does this. You can pass in any object that satisfies the private interface. The idea is, we dont want anyone directly using that private interface directly in their code (no references) so we can rename or move it around to another package and refactor as needed. |
I think this is a limitation of the language / reflection itself. Mainly because these are non-exported structures. |
Hey @jpopadak, sorry I never followed up on this. It was forever in my TODO box, but never got to it. My idea was not to close it until I have dived deeper into that part of the language. Since you closed the issue, does it mean this is not a problem for you anymore or you worked around it? |
I accidentally closed it. I must have clicked the button when reading back through it. 🤦♂ |
In my code base, I use many private interfaces to prevent package pollution.
I have an interface in my source code:
However, I cannot use pegomock to generate a mock for the given interface even though it is exported. I dont want to change the package my test file to be
auth
as it allows direct access to package members (we want to do API only testing and remove dependency on source code).The text was updated successfully, but these errors were encountered: