-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
client.Patch implementations are no longer gomock-friendly #1438
Comments
I have a hard time understanding what exactly go mock is doing here and why. Why is it looking at the private properties of the patch implementation rather than at its exported methods and the result of calling them? None of our api compatibility testing checks compatibility of unexported types. If there is any expectation around compatibility of those, it needs to be agreed upon, formalized and verified in CI. I can already tell you though that I am not a fan doing any of that. The very reason for exporting some things and not exporting others is to convey the message if a compatibility promise is given or not. |
/close |
@ialidzhikov: Closing this issue. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
After #1406, the client.Patch implementations are no longer gomock-friendly.
So we have unit tests that use gomock. Let's have the following example to get a better understanding.
pkg/utils.go
pkg/utils_test.go
Note:
MockClient
is a mock generated with gomockWith sigs.k8s.io/controller-runtime < v0.8.3 this test is working perfectly fine.
#1406 (also cherry-picked into release-0.8 branch) introduces a field of type func (
createPatch
) in themergeFromPatch
struct. This breaks the naive gomock expectations. The reason is that themergeFromPatch
struct has now a function attribute (createPatch
), and as gomock is usingreflect.DeepEqual
under the hood, the comparison now fails:Example of such failure with
sigs.k8s.io/controller-runtime@v0.8.3
:The text was updated successfully, but these errors were encountered: