-
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
Variadic function issues. #766
Comments
Hello, please provide a reproducer. Without this, I cannot provide any help. |
This worked on Mockery v2.20.2 |
I would presume that it has to do with this commit d119c66 |
I have tested on v2.40.0, and everything works, this is the version right before d119c66 so I am fairly confident that it is the cause. |
I think the thing to do here is add your example interface as a fixture and have mockery generate it within this project (mainly for testing/backwards compat reasons), then figure out precisely why this fails. Variadic argument have been the bane of my existence in this project, so I'm guessing we'll need yet another special exception for whatever is going wrong here. |
I'm experiencing the same issues here - especially with trying to mock the AWS SDK Go V2 interfaces. As an example, see this struct. Not a bash on this project (thank you for supporting this) but for the time being we've been pushing folks to use gomock instead since they seem to handle variadic arguments well. |
I'll do what I can to fix this, if anyone would be able to submit a PR that would be great, I probably can't get to it for the next few weeks due to being busy at work. I hope to not drive people away to the main competition for this project, that irks me :) |
There are two bugs fixed in this commit: 1. As noted in issue vektra#766, mockery failed to generate a mock because it incorrectly considered the return values themselves to be variadic, which is impossible. The fix is to always consider return tuples non-variadic. 2. The `.EXPECT()` struct had an incorrect signature when the argument was a variadic function. The reason was because it triggered off the presence of `"..."` in the type string instead of triggering off the variadic-ness of the outer function. The fix was to simply use the `variadic` flag to determine if the last argument should be variadic.
@shortsyoungster @gurudesu I found the issue and submitted a PR to fix it. If the tests pass I will merge and tag the fix. Sorry for the delay in getting to this. @gurudesu after you told me you were telling people to use gomock I knew I wouldn't be able to sleep until my competition is crushed, so I hope this fixes your issue 😅 This bug actually had nothing to do with the variadic-ness of the function (although I did find a separate bug that I don't think was part of the original complaint here). It was failing on the return value of the function argument. Details in the linked PR. PS I guess a way to get me to do stuff is to just say gomock does something better. That should never be the case in my opinion! |
Thanks @LandonTClipp! Will try this out and recommend folks in my org to just upgrade 👍 |
This worked for me @LandonTClipp. Thank you so much! |
PLEASE READ
DO NOT submit tickets without first using the latest version of Golang, clearing your local golang package cache, and re-building mockery using the latest Golang 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 am getting this error from mockery for my interface that uses variadic functions. I get it even after setting the flag
--unroll-variadic=False
.ERR Interface conversion: types.Type is *types.Named, not *types.Slice dry-run=false interface=Name qualified-name=FilePath version=v2.42.0
. Deleting the interface methods that use the variadic input fixes the issue.Mockery Version
2.42.0
Golang Version
1.22
Installation Method
Steps to Reproduce
Expected Behavior
Mock is generated.
Actual Behavior
Blank mock, and the following error:
ERR Interface conversion: types.Type is *types.Named, not *types.Slice dry-run=false interface=Name qualified-name=FilePath version=v2.42.0
The text was updated successfully, but these errors were encountered: