diff --git a/api_test.go b/api_test.go index 963c213..1ab1b1d 100644 --- a/api_test.go +++ b/api_test.go @@ -29,7 +29,7 @@ import ( ) func TestEndpoints_ServeHTTPNotFound(t *testing.T) { - req, _ := http.NewRequest(http.MethodGet, "http://localhost", nil) + req := httptest.NewRequest(http.MethodGet, "http://localhost", nil) w := httptest.NewRecorder() var es Endpoints @@ -71,9 +71,7 @@ func TestEndpoints_ServeHTTP(t *testing.T) { http.MethodConnect, } for _, method := range methods { - req, err := http.NewRequest(strings.ToUpper(method), "http://localhost", nil) - assert.Nil(t, err) - + req := httptest.NewRequest(strings.ToUpper(method), "http://localhost", nil) w := httptest.NewRecorder() es.ServeHTTP(w, req) assert.Equal(t, strings.ToUpper(w.Body.String()), strings.ToUpper(method)) diff --git a/types/types_test.go b/types/types_test.go index f0d691f..9613d28 100644 --- a/types/types_test.go +++ b/types/types_test.go @@ -5,6 +5,7 @@ package types import ( "context" "net/http" + "net/http/httptest" "testing" "github.com/stretchr/testify/assert" @@ -137,7 +138,7 @@ func TestAddURLParamsToContext(t *testing.T) { } func TestURLParam(t *testing.T) { - req, _ := http.NewRequest(http.MethodGet, "/", nil) + req := httptest.NewRequest(http.MethodGet, "/", nil) ctx := AddURLParamsToContext(req.Context(), map[string]string{ "name": "zc", })