-
Notifications
You must be signed in to change notification settings - Fork 183
Fix toolregistrytest by using fake #5627
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
Conversation
Signed-off-by: Yoshiki Fujikane <[email protected]>
Signed-off-by: Yoshiki Fujikane <[email protected]>
Signed-off-by: Yoshiki Fujikane <[email protected]>
Signed-off-by: Yoshiki Fujikane <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #5627 +/- ##
==========================================
+ Coverage 26.54% 26.57% +0.02%
==========================================
Files 477 477
Lines 50666 50644 -22
==========================================
+ Hits 13450 13458 +8
+ Misses 36153 36128 -25
+ Partials 1063 1058 -5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
func (r *ToolRegistry) newTmpDir() (string, error) { | ||
return os.MkdirTemp(r.tmpDir, "") | ||
type fakeClient struct { | ||
pipedservicetest.MockPluginServiceClient |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use it to reduce the cost of maintaining fake implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[IMO]
Using gomock only for this embedding is a bit complex.
How about embedding service.PluginServiceClient instead of generated mock?
type PluginServiceClient interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, sounds good!
I thought we needed the actual instance to override the specific method. 🙏
It works fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree to use fake in the toolregistrytest.
I commented on how we prepare the fake.
func (r *ToolRegistry) newTmpDir() (string, error) { | ||
return os.MkdirTemp(r.tmpDir, "") | ||
type fakeClient struct { | ||
pipedservicetest.MockPluginServiceClient |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[IMO]
Using gomock only for this embedding is a bit complex.
How about embedding service.PluginServiceClient instead of generated mock?
type PluginServiceClient interface { |
Signed-off-by: Yoshiki Fujikane <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 👍
What this PR does:
as title
Why we need it:
It is better to use the same type in both the cases used in actual logic and test like
zaptest.
https://github.com/uber-go/zap/blob/master/zaptest/logger.go#L77
The users don't need to define an additional interface to replace the tool registry on the test.
Which issue(s) this PR fixes:
Fixes #
Does this PR introduce a user-facing change?: