-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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
tests: remaining errors.Is conversions #18634
base: main
Are you sure you want to change the base?
tests: remaining errors.Is conversions #18634
Conversation
Signed-off-by: redwrasse <[email protected]>
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: redwrasse 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 @redwrasse. 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. |
Signed-off-by: redwrasse <[email protected]>
Signed-off-by: redwrasse <[email protected]>
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files
... and 24 files with indirect coverage changes @@ Coverage Diff @@
## main #18634 +/- ##
==========================================
+ Coverage 68.81% 68.82% +0.01%
==========================================
Files 420 420
Lines 35522 35535 +13
==========================================
+ Hits 24443 24456 +13
- Misses 9651 9653 +2
+ Partials 1428 1426 -2 Continue to review full report in Codecov by Sentry.
|
Hi @redwrasse, thanks for opening this pull request. I know this is a draft, but I see the following instances that need to be updated:
|
Signed-off-by: redwrasse <[email protected]>
Added those is @ivanvc . Let me know if you see anymore, otherwise I'll mark this ready for review. |
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 suggest to address nil error before calling errors.Is()
By the way, have you considered activate errorlint with golangci, that can be very helpful.
You can see how I did that on prometheus if you need an idea on how to split the work
@@ -193,7 +194,7 @@ func getMemberList(cx ctlCtx, serializable bool) (etcdserverpb.MemberListRespons | |||
|
|||
resp := etcdserverpb.MemberListResponse{} | |||
dec := json.NewDecoder(strings.NewReader(txt)) | |||
if err := dec.Decode(&resp); err == io.EOF { | |||
if err := dec.Decode(&resp); errors.Is(err, io.EOF) { |
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.
if err := dec.Decode(&resp); errors.Is(err, io.EOF) { | |
if err := dec.Decode(&resp); err != nil && errors.Is(err, io.EOF) { |
@@ -221,7 +222,7 @@ func memberListWithHexTest(cx ctlCtx) { | |||
} | |||
hexResp := etcdserverpb.MemberListResponse{} | |||
dec := json.NewDecoder(strings.NewReader(txt)) | |||
if err := dec.Decode(&hexResp); err == io.EOF { | |||
if err := dec.Decode(&hexResp); errors.Is(err, io.EOF) { |
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.
if err := dec.Decode(&hexResp); errors.Is(err, io.EOF) { | |
if err := dec.Decode(&hexResp); err != nil && errors.Is(err, io.EOF) { |
@@ -156,7 +157,7 @@ func getSnapshotStatus(cx ctlCtx, fpath string) (snapshot.Status, error) { | |||
|
|||
resp := snapshot.Status{} | |||
dec := json.NewDecoder(strings.NewReader(txt)) | |||
if err := dec.Decode(&resp); err == io.EOF { | |||
if err := dec.Decode(&resp); errors.Is(err, io.EOF) { |
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.
if err := dec.Decode(&resp); errors.Is(err, io.EOF) { | |
if err := dec.Decode(&resp); err != nil && errors.Is(err, io.EOF) { |
@@ -64,7 +65,7 @@ func ExampleMutex_TryLock() { | |||
if err = m2.TryLock(context.TODO()); err == nil { | |||
log.Fatal("should not acquire lock") | |||
} | |||
if err == concurrency.ErrLocked { | |||
if errors.Is(err, concurrency.ErrLocked) { |
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.
if errors.Is(err, concurrency.ErrLocked) { | |
if err != nil && errors.Is(err, concurrency.ErrLocked) { |
@@ -113,7 +114,7 @@ func TestBalancerUnderBlackholeKeepAliveWatch(t *testing.T) { | |||
func TestBalancerUnderBlackholeNoKeepAlivePut(t *testing.T) { | |||
testBalancerUnderBlackholeNoKeepAlive(t, func(cli *clientv3.Client, ctx context.Context) error { | |||
_, err := cli.Put(ctx, "foo", "bar") | |||
if clientv3test.IsClientTimeout(err) || clientv3test.IsServerCtxTimeout(err) || err == rpctypes.ErrTimeout { | |||
if clientv3test.IsClientTimeout(err) || clientv3test.IsServerCtxTimeout(err) || errors.Is(err, rpctypes.ErrTimeout) { |
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.
if clientv3test.IsClientTimeout(err) || clientv3test.IsServerCtxTimeout(err) || errors.Is(err, rpctypes.ErrTimeout) { | |
if clientv3test.IsClientTimeout(err) || clientv3test.IsServerCtxTimeout(err) || err != nil && errors.Is(err, rpctypes.ErrTimeout) { |
@@ -127,11 +128,11 @@ func TestUserErrorAuth(t *testing.T) { | |||
DialOptions: []grpc.DialOption{grpc.WithBlock()}, | |||
} | |||
cfg.Username, cfg.Password = "wrong-id", "123" | |||
if _, err := integration2.NewClient(t, cfg); err != rpctypes.ErrAuthFailed { | |||
if _, err := integration2.NewClient(t, cfg); !errors.Is(err, rpctypes.ErrAuthFailed) { |
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.
if _, err := integration2.NewClient(t, cfg); !errors.Is(err, rpctypes.ErrAuthFailed) { | |
if _, err := integration2.NewClient(t, cfg); !(err != nil && errors.Is(err, rpctypes.ErrAuthFailed)) { |
@@ -116,7 +117,7 @@ func TestUserErrorAuth(t *testing.T) { | |||
authSetupRoot(t, authapi.Auth) | |||
|
|||
// unauthenticated client | |||
if _, err := authapi.UserAdd(context.TODO(), "foo", "bar"); err != rpctypes.ErrUserEmpty { | |||
if _, err := authapi.UserAdd(context.TODO(), "foo", "bar"); !errors.Is(err, rpctypes.ErrUserEmpty) { |
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.
if _, err := authapi.UserAdd(context.TODO(), "foo", "bar"); !errors.Is(err, rpctypes.ErrUserEmpty) { | |
if _, err := authapi.UserAdd(context.TODO(), "foo", "bar"); !(err != nil && errors.Is(err, rpctypes.ErrUserEmpty)) { |
t.Fatalf("expected %v, got %v", rpctypes.ErrUserNotFound, err) | ||
} | ||
|
||
_, err = authapi.UserGrantRole(context.TODO(), "foo", "test-role-does-not-exist") | ||
if err != rpctypes.ErrRoleNotFound { | ||
if !errors.Is(err, rpctypes.ErrRoleNotFound) { |
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.
if !errors.Is(err, rpctypes.ErrRoleNotFound) { | |
if !(err != nil && errors.Is(err, rpctypes.ErrRoleNotFound)) { |
t.Fatalf("expected %v, got %v", rpctypes.ErrUserAlreadyExist, err) | ||
} | ||
|
||
_, err = authapi.UserDelete(context.TODO(), "not-exist-user") | ||
if err != rpctypes.ErrUserNotFound { | ||
if !errors.Is(err, rpctypes.ErrUserNotFound) { |
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.
if !errors.Is(err, rpctypes.ErrUserNotFound) { | |
if !(err != nil && errors.Is(err, rpctypes.ErrUserNotFound)) { |
@@ -41,17 +42,17 @@ func TestUserError(t *testing.T) { | |||
} | |||
|
|||
_, err = authapi.UserAdd(context.TODO(), "foo", "bar") | |||
if err != rpctypes.ErrUserAlreadyExist { | |||
if !errors.Is(err, rpctypes.ErrUserAlreadyExist) { |
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.
if !errors.Is(err, rpctypes.ErrUserAlreadyExist) { | |
if !(err != nil && errors.Is(err, rpctypes.ErrUserAlreadyExist)) { |
tests directory errors.Is conversions, as part of #18576