Skip to content
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

Add back replace-type #898

Merged
merged 8 commits into from
Jan 20, 2025
Merged

Add back replace-type #898

merged 8 commits into from
Jan 20, 2025

Conversation

LandonTClipp
Copy link
Collaborator

@LandonTClipp LandonTClipp commented Jan 20, 2025

Port the replace-type parameter into mockery v3. This changes the config schema used in the v2 replace-type parameter to be more grokable. This is also a practical matter: the somewhat complex parsing mechanism in v2 is replaced by simple struct attributes.

The implementation here is quite different from v2. The templating system in v3 requires type information for all types, and thus we cannot do simple string replacements. We have to call packages.Load on the referenced type so we can get real type information. This means that replace-type will incur additional latency. This latency penalty, however, grants us additional correctness of implementation: the mock templates will have full type information, and if something about the replace-type parameter is wrong (either package path or type name don't exist), mockery will explicitly log this as an error.

This does not implement replacements of type constraints as done in v2: #750. This work still needs to be done.

Per #864

@LandonTClipp LandonTClipp marked this pull request as ready for review January 20, 2025 19:21
@LandonTClipp LandonTClipp changed the title Add back replace-types Add back replace-type Jan 20, 2025
@LandonTClipp LandonTClipp merged commit e307bc6 into vektra:v3 Jan 20, 2025
4 checks passed
@LandonTClipp LandonTClipp deleted the replace_Types branch January 20, 2025 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant