Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ linters:
- testifylint
#- unconvert
- unused
#- usestdlibvars
- usestdlibvars
- whitespace
exclusions:
generated: lax
Expand Down
10 changes: 5 additions & 5 deletions config/http_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ func TestBearerAuthRoundTripper(t *testing.T) {

// Normal flow.
bearerAuthRoundTripper := NewAuthorizationCredentialsRoundTripper("Bearer", NewInlineSecret(BearerToken), fakeRoundTripper)
request, _ := http.NewRequest("GET", "/hitchhiker", nil)
request, _ := http.NewRequest(http.MethodGet, "/hitchhiker", nil)
request.Header.Set("User-Agent", "Douglas Adams mind")
_, err := bearerAuthRoundTripper.RoundTrip(request)
if err != nil {
Expand All @@ -714,7 +714,7 @@ func TestBearerAuthRoundTripper(t *testing.T) {

// Should honor already Authorization header set.
bearerAuthRoundTripperShouldNotModifyExistingAuthorization := NewAuthorizationCredentialsRoundTripper("Bearer", NewInlineSecret(newBearerToken), fakeRoundTripper)
request, _ = http.NewRequest("GET", "/hitchhiker", nil)
request, _ = http.NewRequest(http.MethodGet, "/hitchhiker", nil)
request.Header.Set("Authorization", ExpectedBearer)
_, err = bearerAuthRoundTripperShouldNotModifyExistingAuthorization.RoundTrip(request)
if err != nil {
Expand All @@ -733,7 +733,7 @@ func TestBearerAuthFileRoundTripper(t *testing.T) {

// Normal flow.
bearerAuthRoundTripper := NewAuthorizationCredentialsRoundTripper("Bearer", &FileSecret{file: BearerTokenFile}, fakeRoundTripper)
request, _ := http.NewRequest("GET", "/hitchhiker", nil)
request, _ := http.NewRequest(http.MethodGet, "/hitchhiker", nil)
request.Header.Set("User-Agent", "Douglas Adams mind")
_, err := bearerAuthRoundTripper.RoundTrip(request)
if err != nil {
Expand All @@ -742,7 +742,7 @@ func TestBearerAuthFileRoundTripper(t *testing.T) {

// Should honor already Authorization header set.
bearerAuthRoundTripperShouldNotModifyExistingAuthorization := NewAuthorizationCredentialsRoundTripper("Bearer", &FileSecret{file: MissingBearerTokenFile}, fakeRoundTripper)
request, _ = http.NewRequest("GET", "/hitchhiker", nil)
request, _ = http.NewRequest(http.MethodGet, "/hitchhiker", nil)
request.Header.Set("Authorization", ExpectedBearer)
_, err = bearerAuthRoundTripperShouldNotModifyExistingAuthorization.RoundTrip(request)
if err != nil {
Expand Down Expand Up @@ -2104,7 +2104,7 @@ no_proxy: promcon.io,cncf.io`, proxyServer.URL),
os.Setenv("NO_PROXY", tc.noProxyEnv)
}

req := httptest.NewRequest("GET", tc.targetURL, nil)
req := httptest.NewRequest(http.MethodGet, tc.targetURL, nil)

proxyFunc := proxyConfig.Proxy()
resultURL, err := proxyFunc(req)
Expand Down
12 changes: 6 additions & 6 deletions route/route_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
func TestRedirect(t *testing.T) {
router := New().WithPrefix("/test/prefix")
w := httptest.NewRecorder()
r, err := http.NewRequest("GET", "http://localhost:9090/foo", nil)
r, err := http.NewRequest(http.MethodGet, "http://localhost:9090/foo", nil)
require.NoErrorf(t, err, "Error building test request: %s", err)

router.Redirect(w, r, "/some/endpoint", http.StatusFound)
Expand All @@ -43,7 +43,7 @@ func TestContext(t *testing.T) {
require.Equalf(t, want, got, "Unexpected context value: want %q, got %q", want, got)
})

r, err := http.NewRequest("GET", "http://localhost:9090/test/bar/", nil)
r, err := http.NewRequest(http.MethodGet, "http://localhost:9090/test/bar/", nil)
require.NoErrorf(t, err, "Error building test request: %s", err)
router.ServeHTTP(nil, r)
}
Expand All @@ -62,7 +62,7 @@ func TestContextWithValue(t *testing.T) {
require.Equalf(t, want, got, "Unexpected context value: want %q, got %q", want, got)
})

r, err := http.NewRequest("GET", "http://localhost:9090/test/bar/", nil)
r, err := http.NewRequest(http.MethodGet, "http://localhost:9090/test/bar/", nil)
require.NoErrorf(t, err, "Error building test request: %s", err)
params := map[string]string{
"lorem": "ipsum",
Expand All @@ -85,7 +85,7 @@ func TestContextWithoutValue(t *testing.T) {
require.Equalf(t, want, got, "Unexpected context value: want %q, got %q", want, got)
})

r, err := http.NewRequest("GET", "http://localhost:9090/test", nil)
r, err := http.NewRequest(http.MethodGet, "http://localhost:9090/test", nil)
require.NoErrorf(t, err, "Error building test request: %s", err)
router.ServeHTTP(nil, r)
}
Expand All @@ -111,7 +111,7 @@ func TestInstrumentation(t *testing.T) {
for _, c := range cases {
c.router.Get("/foo", func(w http.ResponseWriter, r *http.Request) {})

r, err := http.NewRequest("GET", "http://localhost:9090/foo", nil)
r, err := http.NewRequest(http.MethodGet, "http://localhost:9090/foo", nil)
require.NoErrorf(t, err, "Error building test request: %s", err)
c.router.ServeHTTP(nil, r)
require.Equalf(t, c.want, got, "Unexpected value: want %q, got %q", c.want, got)
Expand Down Expand Up @@ -151,7 +151,7 @@ func TestInstrumentations(t *testing.T) {
for _, c := range cases {
c.router.Get("/foo", func(w http.ResponseWriter, r *http.Request) {})

r, err := http.NewRequest("GET", "http://localhost:9090/foo", nil)
r, err := http.NewRequest(http.MethodGet, "http://localhost:9090/foo", nil)
require.NoErrorf(t, err, "Error building test request: %s", err)
c.router.ServeHTTP(nil, r)
require.Lenf(t, got, len(c.want), "Unexpected value: want %q, got %q", c.want, got)
Expand Down
2 changes: 1 addition & 1 deletion server/static_file_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func TestServeHttp(t *testing.T) {
for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
rr := httptest.NewRecorder()
req, err := http.NewRequest("GET", "http://localhost/"+c.path, nil)
req, err := http.NewRequest(http.MethodGet, "http://localhost/"+c.path, nil)
require.NoError(t, err)

s := StaticFileServer(dummyFileSystem{})
Expand Down
Loading