golang / mock

GoMock is a mocking framework for the Go programming language.
Apache License 2.0
9.28k stars 610 forks source link

feat: allow setting args for variadic functions #595

Closed bergotorino closed 2 years ago

bergotorino commented 2 years ago

The gomock's Call interface allows for setting a value to a specified argument, making it convinient to work with functions that return data through pointer arguments. However, this is not possible for variadic functions, the error is:

SetArg(1, ...) called for a method with 1 args...

The root cause is that the variadic argument in a form of ...interface{} is threated as single value instead of being treated as slice.

This commit changes this situation by making sure that the variadic arguments that are a slice are treated as slices. As a consequence it is now possible to set argument value for variadic functions.

See: https://github.com/golang/mock/issues/174

googlebot commented 2 years ago

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

:memo: Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

google-cla[bot] commented 2 years ago

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

:memo: Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

bergotorino commented 2 years ago

@googlebot I signed it!

googlebot commented 2 years ago

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

google-cla[bot] commented 2 years ago

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

bergotorino commented 2 years ago

Sure, will do. Thanks for review and sorry for missing your comments on time

mvrahden commented 2 years ago

@bergotorino are you still planning to do this?

codyoss commented 2 years ago

Closing due to lack of response.