-
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
Pegomock resolves real type instead of alias type #117
Comments
One thing to note, this has been happening for a while (not a recent issue / version). My team worked around it by creating their own mock & matchers with the correct type. They copied and pasted the generated ones from Pegomock & changed the imports. Those mocks are still being used today. 😄 |
It is not. Surprisingly, the generation of code "works" and doesn't fail when creating the intermediary prog.go. Instead, it's failing on building of the generated files. The issue here is the incorrect import is used for the type. In the generated file, the concrete type which alias points to is used in the import statement. However, the concrete type exists within This can be fixed by instead of using the type the alias points to, to use the alias type itself (which exists outside of the |
Ah, yes, sorry, now I'm getting it.
It could be a limitation, yes. The code to find the types was potentially written even before type aliases existed, but I haven't checked. Have you check if this still doesn't work when using the |
I just tried it with the |
Creating Pegomock Matchers or Mocks for a type which is an alias for a private
./internal/
package type causes compile errors upon matcher creation.Setup
In the example below,
status.Status
is a type alias denoted here in their code.File:
./myfile.go
Result
When generating a matcher, it instead generates a file using the
./internal/.
package path instead of the public one.The resulting matcher file has this header, referencing the internal package.
File:
./matchers/ptr_to_status_status.go
The same occurs for the Mock itself.
File:
./mock_myinterface_test.go
Thoughts
Is this a limitation around how the types are resolved? Or do we try to find the alias type to place in here?
The text was updated successfully, but these errors were encountered: