diff --git a/Makefile b/Makefile index 5f27dc6..ed40f80 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,6 @@ all: test .PHONY: test test: go test ./... -coverprofile coverage.out - $(MAKE) clean .PHONY: version version: diff --git a/integration_test.go b/integration_test.go index bf67cd2..07643ea 100644 --- a/integration_test.go +++ b/integration_test.go @@ -3,7 +3,6 @@ package swagger_test import ( "context" "io" - "io/ioutil" "net/http" "net/http/httptest" "testing" @@ -171,7 +170,7 @@ func TestIntegration(t *testing.T) { func readBody(t *testing.T, requestBody io.ReadCloser) string { t.Helper() - body, err := ioutil.ReadAll(requestBody) + body, err := io.ReadAll(requestBody) require.NoError(t, err) return string(body) diff --git a/main_test.go b/main_test.go index e257a30..2c1c131 100644 --- a/main_test.go +++ b/main_test.go @@ -4,9 +4,9 @@ import ( "context" "fmt" "io" - "io/ioutil" "net/http" "net/http/httptest" + "os" "strings" "testing" @@ -229,7 +229,7 @@ func TestGenerateAndExposeSwagger(t *testing.T) { require.True(t, strings.Contains(w.Result().Header.Get("content-type"), "application/json")) body := readBody(t, w.Result().Body) - actual, err := ioutil.ReadFile("testdata/users_employees.json") + actual, err := os.ReadFile("testdata/users_employees.json") require.NoError(t, err) require.JSONEq(t, string(actual), body) }) @@ -257,7 +257,7 @@ func TestGenerateAndExposeSwagger(t *testing.T) { require.True(t, strings.Contains(w.Result().Header.Get("content-type"), "application/json")) body := readBody(t, w.Result().Body) - actual, err := ioutil.ReadFile("testdata/users_employees.json") + actual, err := os.ReadFile("testdata/users_employees.json") require.NoError(t, err) require.JSONEq(t, string(actual), body) }) @@ -284,7 +284,7 @@ func TestGenerateAndExposeSwagger(t *testing.T) { require.True(t, strings.Contains(w.Result().Header.Get("content-type"), "text/plain")) body := readBody(t, w.Result().Body) - expected, err := ioutil.ReadFile("testdata/users_employees.yaml") + expected, err := os.ReadFile("testdata/users_employees.yaml") require.NoError(t, err) require.YAMLEq(t, string(expected), body, string(body)) }) @@ -312,7 +312,7 @@ func TestGenerateAndExposeSwagger(t *testing.T) { require.True(t, strings.Contains(w.Result().Header.Get("content-type"), "text/plain")) body := readBody(t, w.Result().Body) - expected, err := ioutil.ReadFile("testdata/users_employees.yaml") + expected, err := os.ReadFile("testdata/users_employees.yaml") require.NoError(t, err) require.YAMLEq(t, string(expected), body, string(body)) }) @@ -367,7 +367,7 @@ func TestGenerateAndExposeSwagger(t *testing.T) { require.True(t, strings.Contains(w.Result().Header.Get("content-type"), "application/json")) body := readBody(t, w.Result().Body) - actual, err := ioutil.ReadFile("testdata/subrouter.json") + actual, err := os.ReadFile("testdata/subrouter.json") require.NoError(t, err) require.JSONEq(t, string(actual), body) }) @@ -403,7 +403,7 @@ func TestGenerateAndExposeSwagger(t *testing.T) { require.True(t, strings.Contains(w.Result().Header.Get("content-type"), "application/json")) body := readBody(t, w.Result().Body) - actual, err := ioutil.ReadFile("testdata/router_with_prefix.json") + actual, err := os.ReadFile("testdata/router_with_prefix.json") require.NoError(t, err) require.JSONEq(t, string(actual), body) }) @@ -412,7 +412,7 @@ func TestGenerateAndExposeSwagger(t *testing.T) { func readBody(t *testing.T, requestBody io.ReadCloser) string { t.Helper() - body, err := ioutil.ReadAll(requestBody) + body, err := io.ReadAll(requestBody) require.NoError(t, err) return string(body) diff --git a/route_test.go b/route_test.go index 3ea4e53..3292126 100644 --- a/route_test.go +++ b/route_test.go @@ -3,9 +3,9 @@ package swagger import ( "context" "fmt" - "io/ioutil" "net/http" "net/http/httptest" + "os" "testing" "github.com/davidebianchi/gswagger/apirouter" @@ -477,7 +477,7 @@ func TestAddRoutes(t *testing.T) { require.Equal(t, http.StatusOK, w.Result().StatusCode) body := readBody(t, w.Result().Body) - expected, err := ioutil.ReadFile(test.fixturesPath) + expected, err := os.ReadFile(test.fixturesPath) require.NoError(t, err) require.JSONEq(t, string(expected), body, "actual json data: %s", body) })