-
Notifications
You must be signed in to change notification settings - Fork 10.2k
etcdctl: add fake client for UT #20270
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
base: main
Are you sure you want to change the base?
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: hwdef The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
Hi @hwdef. Thanks for your PR. I'm waiting for a etcd-io member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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-sigs/prow repository. |
|
/ok-to-test |
|
|
||
| // KV | ||
|
|
||
| type kvStub struct{} |
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.
we need to think about how to pass in the mock response.
Like a fake dict of kvs, a list of alarms.
Can you try to use the fakeclient to test alarm_command as an example of how it should work?
Codecov Report❌ Patch coverage is Additional details and impacted files
... and 27 files with indirect coverage changes @@ Coverage Diff @@
## main #20270 +/- ##
==========================================
+ Coverage 69.16% 69.61% +0.44%
==========================================
Files 422 424 +2
Lines 34841 34907 +66
==========================================
+ Hits 24098 24300 +202
+ Misses 9339 9162 -177
- Partials 1404 1445 +41 Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
6f0f3ff to
e050fdb
Compare
34dcb55 to
ca8b054
Compare
ca8b054 to
abab404
Compare
abab404 to
4cd9111
Compare
4d76620 to
21d330d
Compare
0eb3dff to
364b200
Compare
|
@siyuanfoundation @Elbehery @serathius |
|
Overall this approach works. Another option would be refactor all the functions like @ahrtr would really appreciate your input. Thanks! |
39b15be to
4bb7e7b
Compare
|
/retest |
| func newTestRoot() *cobra.Command { | ||
| root := &cobra.Command{Use: "etcdctl"} | ||
| root.AddGroup(NewKVGroup(), NewClusterMaintenanceGroup(), NewConcurrencyGroup(), NewAuthenticationGroup(), NewUtilityGroup()) | ||
| root.PersistentFlags().StringSlice("endpoints", []string{"127.0.0.1:2379"}, "") |
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.
abstract to a function shared with init()
| "go.etcd.io/etcd/etcdctl/v3/ctlv3/command/fakeclient" | ||
| ) | ||
|
|
||
| func withStdoutCapture(t *testing.T, fn func()) string { |
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.
move this and setupFake to a separate file like test_utils.go
f57b429 to
6634073
Compare
Signed-off-by: hwdef <[email protected]>
6634073 to
983a7ad
Compare
|
|
||
| // GlobalFlags are flags that defined globally | ||
| // and are inherited to all sub-commands. | ||
| type GlobalFlags struct { |
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.
It seems this struct is not very useful to begin with. How about moving the refactor to a separate PR?
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.
check unused flag.
Part of: #20171
/cc @siyuanfoundation @Elbehery