-
Notifications
You must be signed in to change notification settings - Fork 412
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
Mocked Generated Classes using internal package #804
Comments
Does https://vektra.github.io/mockery/latest/features/#replace-types do you what you need? |
@LandonTClipp that does seem to work. I added this to my config which seems to work.
I didn't see any concrete examples on: https://vektra.github.io/mockery/latest/configuration/#parameter-descriptions but if there's a smarter way of doing this let me know. As a side note, do you know why this is acting this way? It's seems peculiar to me. I have other repo classes that don't behave that way but I can't really tell what is different about this class in particular. |
Yes we do know why it happens, the reasons are enumerated in the link I posted above. Basically, the Go AST did not provide any typing information for aliases. They would transparently resolve to the aliased type, so it was impossible for anything parsing the AST to know it was an alias. I did do an investigation of this over a year ago to see if there was a fix with this new We now have go/types support, but I have yet to see if the compiler and export format preserve the typing info during compilation, which is also necessary: golang/go#64208 It doesn't appear that the Go devs have completely fixed this yet, so I'm doubtful there's anything further we can do. |
Okay thank you for the info. I'll close this ticket out and keep my fingers crossed regarding the golang ticket. |
PLEASE READ
DO NOT submit tickets without first using the latest version of Go, clearing your local golang package cache, and re-building mockery using the latest Go version and the latest version of mockery. Please provide evidence this has been done in your issue. Failure to provide this evidence will likely result in your issue being closed.
Description
I'm currently using jet which lets me connect to postgres and run some queries. I'm not sure why this is the behavior and it's only in one of my repo files though the imports look similar.
In my class i import:
The generated mocked class looks like this:
which obviously fails as it's trying to import an internal library. postgres, exports some of the internal equivalent from internal/jet that I'm using.
Mockery Version
2.44.1
Go Version
1.23.0
Installation Method
Steps to Reproduce
run: mockery
Expected Behavior
Mock should not import an internal library.
Actual Behavior
Imported an internal library.
Related files can be found here: https://gist.github.com/safaci2000/34b1cef47a0b733d5cd73337bed16484
The text was updated successfully, but these errors were encountered: