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

Support variadic parameters in augmented mock client #731

Merged
merged 2 commits into from
Jul 17, 2020
Merged

Conversation

ChuntaoLu
Copy link
Contributor

This PR adds support for variadic parameters in the augmented mock client
MockClientWithFixture. This feature applies to any type of clients that
has methods of variadic parameters, but particularly applies to generated
gRPC clients, where each client method accepts the variadic parameter of
type yarpc.CallOption.

One caveat is that Go does not support function comparsion (even
reflect.DeepEqual won't work), see details in
golang/mock#324. So in the case of gRPC mock
clients, it is not possible to match the yarpc.CallOption variadic
parameters, because it internally has a function field. The workout is to
always set Arg{n}Any in the fixture pacakge to the number of variadic
parameters so that macther checks pass for them.

Chuntao Lu added 2 commits July 17, 2020 08:57
This PR adds support for variadic parameters in the augmented mock
client `MockClientWithFixture`. This feature applies to any type of
clients that has methods of variadic parameters, but particularly
applies to generated gRPC clients, where each client method accepts the
variadic parameter of type `yarpc.CallOption`.

One caveat is that Go does not support function comparsion (even
`reflect.DeepEqual` won't work), see details in
golang/mock#324. So in the case of gRPC mock
clients, it is not possible to match the `yarpc.CallOption` variadic
parameters, because it internally has a function field. The workout is
to always set `Arg{n}Any` in the fixture pacakge to the number of
variadic parameters so that macther checks pass for them.
@ChuntaoLu ChuntaoLu requested a review from rpatali July 17, 2020 16:19
@ChuntaoLu ChuntaoLu mentioned this pull request Jul 17, 2020
Copy link
Contributor

@rpatali rpatali left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ChuntaoLu ChuntaoLu merged commit d78103e into master Jul 17, 2020
@ChuntaoLu ChuntaoLu deleted the lu.variadic branch July 17, 2020 17:21
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.

2 participants