Skip to content

Commit

Permalink
Merge pull request etcd-io#17286 from ivanvc/fix-golangci-error-strin…
Browse files Browse the repository at this point in the history
…gs-issues

Fix golangci revive error-strings issues
  • Loading branch information
ahrtr authored Jan 21, 2024
2 parents dd0b052 + fe03e16 commit 15f95ec
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 16 deletions.
12 changes: 7 additions & 5 deletions client/internal/v2/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand Down
10 changes: 5 additions & 5 deletions client/internal/v2/keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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},
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions client/internal/v2/members_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand Down
5 changes: 3 additions & 2 deletions tools/.golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 15f95ec

Please sign in to comment.