From 867b45d86548505be265cab9ba2fde86aee280f2 Mon Sep 17 00:00:00 2001 From: Manjunath A Kumatagi Date: Mon, 22 Apr 2019 07:52:12 -0500 Subject: [PATCH] client: Fix tests for latest golang --- client/client_test.go | 4 ++-- client/keys_test.go | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/client/client_test.go b/client/client_test.go index c66d3b77b..2b4ae4d82 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -422,7 +422,7 @@ func TestHTTPClusterClientDo(t *testing.T) { tt.ctx = context.Background() } resp, _, err := tt.client.Do(tt.ctx, nil) - if !reflect.DeepEqual(tt.wantErr, err) { + if (tt.wantErr == nil && tt.wantErr != err) || (tt.wantErr != nil && tt.wantErr.Error() != err.Error()) { t.Errorf("#%d: got err=%v, want=%v", i, err, tt.wantErr) continue } @@ -726,7 +726,7 @@ func TestRedirectFollowingHTTPClient(t *testing.T) { for i, tt := range tests { client := &redirectFollowingHTTPClient{client: tt.client, checkRedirect: tt.checkRedirect} resp, _, err := client.Do(context.Background(), nil) - if !reflect.DeepEqual(tt.wantErr, err) { + if (tt.wantErr == nil && tt.wantErr != err) || (tt.wantErr != nil && tt.wantErr.Error() != err.Error()) { t.Errorf("#%d: got err=%v, want=%v", i, err, tt.wantErr) continue } diff --git a/client/keys_test.go b/client/keys_test.go index 0e190cf59..34428bb0a 100644 --- a/client/keys_test.go +++ b/client/keys_test.go @@ -994,12 +994,13 @@ func TestHTTPKeysAPIWatcherAction(t *testing.T) { } for i, tt := range tests { + testError := errors.New("fail!") kAPI := &httpKeysAPI{ - client: &staticHTTPClient{err: errors.New("fail!")}, + client: &staticHTTPClient{err: testError}, } want := &httpWatcher{ - client: &staticHTTPClient{err: errors.New("fail!")}, + client: &staticHTTPClient{err: testError}, nextWait: tt.want, }