From a82047f6fb6890231070ea58a512e47dda13918a Mon Sep 17 00:00:00 2001 From: Archish Thakkar <archishthakkar@gmail.com> Date: Wed, 11 Sep 2024 15:17:29 +0000 Subject: [PATCH] Lint fixes for customaction package --- .../shared/customaction/customaction_test.go | 45 ++++++++++--------- support/lint_last_known_acceptable.txt | 20 --------- 2 files changed, 23 insertions(+), 42 deletions(-) diff --git a/internal/command/shared/customaction/customaction_test.go b/internal/command/shared/customaction/customaction_test.go index 7b691243..b2a0c218 100644 --- a/internal/command/shared/customaction/customaction_test.go +++ b/internal/command/shared/customaction/customaction_test.go @@ -8,6 +8,7 @@ import ( "net/http" "testing" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "gitlab.com/gitlab-org/gitlab-shell/v14/client/testserver" @@ -24,32 +25,32 @@ func TestExecuteEOFSent(t *testing.T) { Path: "/geo/proxy/info_refs_receive_pack", Handler: func(w http.ResponseWriter, r *http.Request) { b, err := io.ReadAll(r.Body) - require.NoError(t, err) + assert.NoError(t, err) var request *Request - require.NoError(t, json.Unmarshal(b, &request)) + assert.NoError(t, json.Unmarshal(b, &request)) - require.Equal(t, request.Data.UserID, who) - require.Empty(t, request.Output) + assert.Equal(t, request.Data.UserID, who) + assert.Empty(t, request.Output) err = json.NewEncoder(w).Encode(Response{Result: []byte("custom")}) - require.NoError(t, err) + assert.NoError(t, err) }, }, { Path: "/geo/proxy/receive_pack", Handler: func(w http.ResponseWriter, r *http.Request) { b, err := io.ReadAll(r.Body) - require.NoError(t, err) + assert.NoError(t, err) var request *Request - require.NoError(t, json.Unmarshal(b, &request)) + assert.NoError(t, json.Unmarshal(b, &request)) - require.Equal(t, request.Data.UserID, who) - require.Equal(t, "0009input", string(request.Output)) + assert.Equal(t, request.Data.UserID, who) + assert.Equal(t, "0009input", string(request.Output)) err = json.NewEncoder(w).Encode(Response{Result: []byte("output")}) - require.NoError(t, err) + assert.NoError(t, err) }, }, } @@ -82,7 +83,7 @@ func TestExecuteEOFSent(t *testing.T) { // expect printing of info message, "custom" string from the first request // and "output" string from the second request - require.Equal(t, "customoutput", outBuf.String()) + assert.Equal(t, "customoutput", outBuf.String()) } func TestExecuteNoEOFSent(t *testing.T) { @@ -93,32 +94,32 @@ func TestExecuteNoEOFSent(t *testing.T) { Path: "/geo/proxy/info_refs_upload_pack", Handler: func(w http.ResponseWriter, r *http.Request) { b, err := io.ReadAll(r.Body) - require.NoError(t, err) + assert.NoError(t, err) var request *Request - require.NoError(t, json.Unmarshal(b, &request)) + assert.NoError(t, json.Unmarshal(b, &request)) - require.Equal(t, request.Data.UserID, who) - require.Empty(t, request.Output) + assert.Equal(t, request.Data.UserID, who) + assert.Empty(t, request.Output) err = json.NewEncoder(w).Encode(Response{Result: []byte("custom")}) - require.NoError(t, err) + assert.NoError(t, err) }, }, { Path: "/geo/proxy/upload_pack", Handler: func(w http.ResponseWriter, r *http.Request) { b, err := io.ReadAll(r.Body) - require.NoError(t, err) + assert.NoError(t, err) var request *Request - require.NoError(t, json.Unmarshal(b, &request)) + assert.NoError(t, json.Unmarshal(b, &request)) - require.Equal(t, request.Data.UserID, who) - require.Equal(t, "0032want 343d70886785dc1f98aaf70f3b4ca87c93a5d0dd\n", string(request.Output)) + assert.Equal(t, request.Data.UserID, who) + assert.Equal(t, "0032want 343d70886785dc1f98aaf70f3b4ca87c93a5d0dd\n", string(request.Output)) err = json.NewEncoder(w).Encode(Response{Result: []byte("output")}) - require.NoError(t, err) + assert.NoError(t, err) }, }, } @@ -151,5 +152,5 @@ func TestExecuteNoEOFSent(t *testing.T) { // expect printing of info message, "custom" string from the first request // and "output" string from the second request - require.Equal(t, "customoutput", outBuf.String()) + assert.Equal(t, "customoutput", outBuf.String()) } diff --git a/support/lint_last_known_acceptable.txt b/support/lint_last_known_acceptable.txt index 6fa38234..28391a49 100644 --- a/support/lint_last_known_acceptable.txt +++ b/support/lint_last_known_acceptable.txt @@ -173,26 +173,6 @@ internal/command/readwriter/readwriter.go:7:6: exported: exported type ReadWrite internal/command/receivepack/gitalycall_test.go:24:4: S1038: should use t.Logf(...) instead of t.Log(fmt.Sprintf(...)) (gosimple) internal/command/receivepack/gitalycall_test.go:31:5: var-naming: struct field keyId should be keyID (revive) internal/command/receivepack/gitalycall_test.go:98:5: expected-actual: need to reverse actual and expected values (testifylint) -internal/command/shared/customaction/customaction_test.go:27:5: go-require: do not use require in http handlers (testifylint) -internal/command/shared/customaction/customaction_test.go:30:5: go-require: do not use require in http handlers (testifylint) -internal/command/shared/customaction/customaction_test.go:32:5: go-require: do not use require in http handlers (testifylint) -internal/command/shared/customaction/customaction_test.go:33:5: go-require: do not use require in http handlers (testifylint) -internal/command/shared/customaction/customaction_test.go:36:5: go-require: do not use require in http handlers (testifylint) -internal/command/shared/customaction/customaction_test.go:43:5: go-require: do not use require in http handlers (testifylint) -internal/command/shared/customaction/customaction_test.go:46:5: go-require: do not use require in http handlers (testifylint) -internal/command/shared/customaction/customaction_test.go:48:5: go-require: do not use require in http handlers (testifylint) -internal/command/shared/customaction/customaction_test.go:49:5: go-require: do not use require in http handlers (testifylint) -internal/command/shared/customaction/customaction_test.go:52:5: go-require: do not use require in http handlers (testifylint) -internal/command/shared/customaction/customaction_test.go:96:5: go-require: do not use require in http handlers (testifylint) -internal/command/shared/customaction/customaction_test.go:99:5: go-require: do not use require in http handlers (testifylint) -internal/command/shared/customaction/customaction_test.go:101:5: go-require: do not use require in http handlers (testifylint) -internal/command/shared/customaction/customaction_test.go:102:5: go-require: do not use require in http handlers (testifylint) -internal/command/shared/customaction/customaction_test.go:105:5: go-require: do not use require in http handlers (testifylint) -internal/command/shared/customaction/customaction_test.go:112:5: go-require: do not use require in http handlers (testifylint) -internal/command/shared/customaction/customaction_test.go:115:5: go-require: do not use require in http handlers (testifylint) -internal/command/shared/customaction/customaction_test.go:117:5: go-require: do not use require in http handlers (testifylint) -internal/command/shared/customaction/customaction_test.go:118:5: go-require: do not use require in http handlers (testifylint) -internal/command/shared/customaction/customaction_test.go:121:5: go-require: do not use require in http handlers (testifylint) internal/config/config.go:1:1: package-comments: should have a package comment (revive) internal/config/config.go:21:2: G101: Potential hardcoded credentials (gosec) internal/config/config.go:24:6: exported: exported type YamlDuration should have comment or be unexported (revive) -- GitLab