From fe03e168a35e10f431163120eae8f66c3fccaada Mon Sep 17 00:00:00 2001 From: Ivan Valdes Date: Thu, 21 Dec 2023 11:52:32 -0800 Subject: [PATCH] *: fix golangci error-strings issues Signed-off-by: Ivan Valdes --- client/internal/v2/client_test.go | 12 +++++++----- client/internal/v2/keys_test.go | 10 +++++----- client/internal/v2/members_test.go | 8 ++++---- tools/.golangci.yaml | 5 +++-- 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/client/internal/v2/client_test.go b/client/internal/v2/client_test.go index 8c5eba447f1..83aae018dad 100644 --- a/client/internal/v2/client_test.go +++ b/client/internal/v2/client_test.go @@ -318,7 +318,7 @@ func TestSimpleHTTPClientDoHeaderTimeout(t *testing.T) { } func TestHTTPClusterClientDo(t *testing.T) { - fakeErr := errors.New("fake!") + fakeErr := errors.New("fake") fakeURL := url.URL{} tests := []struct { client *httpClusterClient @@ -583,11 +583,11 @@ func TestRedirectFollowingHTTPClient(t *testing.T) { client: &multiStaticHTTPClient{ responses: []staticHTTPResponse{ { - err: errors.New("fail!"), + err: errors.New("fail"), }, }, }, - wantErr: errors.New("fail!"), + wantErr: errors.New("fail"), }, // no need to follow redirect if none given @@ -723,7 +723,9 @@ func TestRedirectFollowingHTTPClient(t *testing.T) { }, }, }, + //revive:disable:error-strings wantErr: errors.New("location header not valid URL: :"), + //revive:enable:error-strings }, // fail if redirects checked way too many times @@ -830,7 +832,7 @@ func TestHTTPClusterClientSync(t *testing.T) { func TestHTTPClusterClientSyncFail(t *testing.T) { cf := newStaticHTTPClientFactory([]staticHTTPResponse{ - {err: errors.New("fail!")}, + {err: errors.New("fail")}, }) hc := &httpClusterClient{ @@ -886,7 +888,7 @@ func TestHTTPClusterClientAutoSyncCancelContext(t *testing.T) { func TestHTTPClusterClientAutoSyncFail(t *testing.T) { cf := newStaticHTTPClientFactory([]staticHTTPResponse{ - {err: errors.New("fail!")}, + {err: errors.New("fail")}, }) hc := &httpClusterClient{ diff --git a/client/internal/v2/keys_test.go b/client/internal/v2/keys_test.go index 05aeb3f7e10..f3ed8b10eb2 100644 --- a/client/internal/v2/keys_test.go +++ b/client/internal/v2/keys_test.go @@ -892,7 +892,7 @@ func TestHTTPWatcherNextFail(t *testing.T) { tests := []httpClient{ // generic HTTP client failure &staticHTTPClient{ - err: errors.New("fail!"), + err: errors.New("fail"), }, // unusable status code @@ -994,7 +994,7 @@ func TestHTTPKeysAPIWatcherAction(t *testing.T) { } for i, tt := range tests { - testError := errors.New("fail!") + testError := errors.New("fail") kAPI := &httpKeysAPI{ client: &staticHTTPClient{err: testError}, } @@ -1080,7 +1080,7 @@ func TestHTTPKeysAPISetError(t *testing.T) { tests := []httpClient{ // generic HTTP client failure &staticHTTPClient{ - err: errors.New("fail!"), + err: errors.New("fail"), }, // unusable status code @@ -1191,7 +1191,7 @@ func TestHTTPKeysAPIGetError(t *testing.T) { tests := []httpClient{ // generic HTTP client failure &staticHTTPClient{ - err: errors.New("fail!"), + err: errors.New("fail"), }, // unusable status code @@ -1310,7 +1310,7 @@ func TestHTTPKeysAPIDeleteError(t *testing.T) { tests := []httpClient{ // generic HTTP client failure &staticHTTPClient{ - err: errors.New("fail!"), + err: errors.New("fail"), }, // unusable status code diff --git a/client/internal/v2/members_test.go b/client/internal/v2/members_test.go index ecea78096c8..1ad0c4c4024 100644 --- a/client/internal/v2/members_test.go +++ b/client/internal/v2/members_test.go @@ -371,7 +371,7 @@ func TestHTTPMembersAPIAddError(t *testing.T) { // generic httpClient failure { peerURL: okPeer, - client: &staticHTTPClient{err: errors.New("fail!")}, + client: &staticHTTPClient{err: errors.New("fail")}, }, // unrecognized HTTP status code @@ -456,7 +456,7 @@ func TestHTTPMembersAPIRemoveFail(t *testing.T) { tests := []httpClient{ // generic error &staticHTTPClient{ - err: errors.New("fail!"), + err: errors.New("fail"), }, // unexpected HTTP status code @@ -509,7 +509,7 @@ func TestHTTPMembersAPIListSuccess(t *testing.T) { func TestHTTPMembersAPIListError(t *testing.T) { tests := []httpClient{ // generic httpClient failure - &staticHTTPClient{err: errors.New("fail!")}, + &staticHTTPClient{err: errors.New("fail")}, // unrecognized HTTP status code &staticHTTPClient{ @@ -569,7 +569,7 @@ func TestHTTPMembersAPILeaderSuccess(t *testing.T) { func TestHTTPMembersAPILeaderError(t *testing.T) { tests := []httpClient{ // generic httpClient failure - &staticHTTPClient{err: errors.New("fail!")}, + &staticHTTPClient{err: errors.New("fail")}, // unrecognized HTTP status code &staticHTTPClient{ diff --git a/tools/.golangci.yaml b/tools/.golangci.yaml index 2ab68681cc8..34d3878f909 100644 --- a/tools/.golangci.yaml +++ b/tools/.golangci.yaml @@ -83,9 +83,10 @@ linters-settings: # please keep this alphabetized - name: context-keys-type severity: error disabled: false - # TODO: enable the following rules - name: error-strings - disabled: true + severity: error + disabled: false + # TODO: enable the following rules - name: var-naming disabled: true - name: exported