Skip to content

Commit 329c08a

Browse files
committed
fix: Address linter issues in ratelimit tests
- Use http.NoBody instead of nil - Use http.MethodGet constant instead of string - Fix assert.Equal argument order (expected, actual)
1 parent 2664aad commit 329c08a

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

config/confighttp/ratelimit_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func TestServerRateLimit(t *testing.T) {
4545
require.NoError(t, err)
4646

4747
// test
48-
srv.Handler.ServeHTTP(&httptest.ResponseRecorder{}, httptest.NewRequest("GET", "/", nil))
48+
srv.Handler.ServeHTTP(&httptest.ResponseRecorder{}, httptest.NewRequest(http.MethodGet, "/", http.NoBody))
4949

5050
// verify
5151
assert.True(t, handlerCalled)
@@ -85,10 +85,10 @@ func TestRejectedServerRateLimit(t *testing.T) {
8585

8686
// test
8787
response := &httptest.ResponseRecorder{}
88-
srv.Handler.ServeHTTP(response, httptest.NewRequest("GET", "/", nil))
88+
srv.Handler.ServeHTTP(response, httptest.NewRequest(http.MethodGet, "/", http.NoBody))
8989

9090
// verify
91-
assert.Equal(t, response.Result().StatusCode, http.StatusTooManyRequests)
91+
assert.Equal(t, http.StatusTooManyRequests, response.Result().StatusCode)
9292
assert.Equal(t, response.Result().Status, fmt.Sprintf("%v %s", http.StatusTooManyRequests, http.StatusText(http.StatusTooManyRequests)))
9393
}
9494

0 commit comments

Comments
 (0)