diff --git a/client.go b/client.go index 3f6e9ef..e97ab2d 100644 --- a/client.go +++ b/client.go @@ -2,7 +2,6 @@ package httpaux import ( "io" - "io/ioutil" "net/http" ) @@ -20,7 +19,7 @@ var _ Client = (*http.Client)(nil) // does nothing. func Cleanup(r *http.Response) { if r != nil && r.Body != nil { - io.Copy(ioutil.Discard, r.Body) + io.Copy(io.Discard, r.Body) r.Body.Close() } } diff --git a/client/middleware_test.go b/client/middleware_test.go index 964c706..b1a5b10 100644 --- a/client/middleware_test.go +++ b/client/middleware_test.go @@ -3,7 +3,6 @@ package client import ( "errors" "io" - "io/ioutil" "net/http" "net/http/httptest" "strconv" @@ -77,7 +76,7 @@ func (suite *ChainTestSuite) assertRequest(expectedOrder []int, client httpaux.C suite.Require().NoError(err) defer response.Body.Close() - io.Copy(ioutil.Discard, response.Body) + io.Copy(io.Discard, response.Body) suite.Equal(expectedOrder, suite.order, "the decorators did not run in the expected order") suite.Equal(299, response.StatusCode, "the test server was not invoked") } diff --git a/erraux/encoder_test.go b/erraux/encoder_test.go index 9b8ab58..19a8700 100644 --- a/erraux/encoder_test.go +++ b/erraux/encoder_test.go @@ -3,7 +3,7 @@ package erraux import ( "context" "errors" - "io/ioutil" + "io" "net/http" "net/http/httptest" "testing" @@ -29,7 +29,7 @@ func (suite *EncoderTestSuite) result(rw *httptest.ResponseRecorder) (statusCode h = result.Header suite.Equal("application/json", h.Get("Content-Type")) - b, err := ioutil.ReadAll(result.Body) + b, err := io.ReadAll(result.Body) suite.Require().NoError(err) body = string(b) diff --git a/gate/middleware_test.go b/gate/middleware_test.go index 998ed63..d936220 100644 --- a/gate/middleware_test.go +++ b/gate/middleware_test.go @@ -3,7 +3,6 @@ package gate import ( "errors" "io" - "io/ioutil" "net/http" "net/http/httptest" "testing" @@ -174,7 +173,7 @@ func (suite *ClientTestSuite) TestDefaultOpen() { suite.NoError(err) suite.Require().NotNil(response) suite.Equal(277, response.StatusCode) - io.Copy(ioutil.Discard, response.Body) + io.Copy(io.Discard, response.Body) response.Body.Close() }) @@ -185,7 +184,7 @@ func (suite *ClientTestSuite) TestDefaultOpen() { suite.NoError(err) suite.Require().NotNil(response) suite.Equal(277, response.StatusCode) - io.Copy(ioutil.Discard, response.Body) + io.Copy(io.Discard, response.Body) response.Body.Close() }) } @@ -198,7 +197,7 @@ func (suite *ClientTestSuite) TestDefaultClosed() { response, err := suite.checkRoundTripper(rt) if !suite.Nil(response) { - io.Copy(ioutil.Discard, response.Body) + io.Copy(io.Discard, response.Body) response.Body.Close() } @@ -210,7 +209,7 @@ func (suite *ClientTestSuite) TestDefaultClosed() { response, err := suite.checkRoundTripper(rt) if !suite.Nil(response) { - io.Copy(ioutil.Discard, response.Body) + io.Copy(io.Discard, response.Body) response.Body.Close() } @@ -229,7 +228,7 @@ func (suite *ClientTestSuite) TestCustomOpen() { suite.NoError(err) suite.Require().NotNil(response) suite.Equal(277, response.StatusCode) - io.Copy(ioutil.Discard, response.Body) + io.Copy(io.Discard, response.Body) response.Body.Close() }) @@ -243,7 +242,7 @@ func (suite *ClientTestSuite) TestCustomOpen() { suite.NoError(err) suite.Require().NotNil(response) suite.Equal(277, response.StatusCode) - io.Copy(ioutil.Discard, response.Body) + io.Copy(io.Discard, response.Body) response.Body.Close() }) } @@ -259,7 +258,7 @@ func (suite *ClientTestSuite) TestCustomClosed() { response, err := suite.checkRoundTripper(rt) if !suite.Nil(response) { - io.Copy(ioutil.Discard, response.Body) + io.Copy(io.Discard, response.Body) response.Body.Close() } @@ -274,7 +273,7 @@ func (suite *ClientTestSuite) TestCustomClosed() { response, err := suite.checkRoundTripper(rt) if !suite.Nil(response) { - io.Copy(ioutil.Discard, response.Body) + io.Copy(io.Discard, response.Body) response.Body.Close() } diff --git a/httpmock/body_test.go b/httpmock/body_test.go index deaaddf..0ccaebf 100644 --- a/httpmock/body_test.go +++ b/httpmock/body_test.go @@ -4,7 +4,6 @@ import ( "bytes" "fmt" "io" - "io/ioutil" "testing" "github.com/stretchr/testify/suite" @@ -17,7 +16,7 @@ type BodyReadCloserTestSuite struct { func (suite *BodyReadCloserTestSuite) testBodyReadCloser(body *BodyReadCloser, expected []byte) { suite.Require().NotNil(body) - actual, err := ioutil.ReadAll(body) + actual, err := io.ReadAll(body) suite.Equal(expected, actual) suite.NoError(err) @@ -58,7 +57,7 @@ func (suite *BodyReadCloserTestSuite) TestBodyf() { } func (suite *BodyReadCloserTestSuite) TestNopCloser() { - body := ioutil.NopCloser( + body := io.NopCloser( bytes.NewBufferString("this body doesn't implement Closeable"), ) diff --git a/httpmock/requestChecker_test.go b/httpmock/requestChecker_test.go index 775f260..3e02fca 100644 --- a/httpmock/requestChecker_test.go +++ b/httpmock/requestChecker_test.go @@ -3,7 +3,6 @@ package httpmock import ( "errors" "io" - "io/ioutil" "net/http" "net/url" "strconv" @@ -370,7 +369,7 @@ func (suite *RequestCheckerTestSuite) TestBody() { }() request := &http.Request{ - Body: ioutil.NopCloser(reader), + Body: io.NopCloser(reader), } t := wrapTestingT(suite.T()) @@ -462,7 +461,7 @@ func (suite *RequestCheckerTestSuite) TestBodyJSON() { }() request := &http.Request{ - Body: ioutil.NopCloser(reader), + Body: io.NopCloser(reader), } t := wrapTestingT(suite.T()) diff --git a/httpmock/roundTripper_test.go b/httpmock/roundTripper_test.go index 1c1f278..ee8d795 100644 --- a/httpmock/roundTripper_test.go +++ b/httpmock/roundTripper_test.go @@ -4,7 +4,6 @@ package httpmock import ( "errors" "io" - "io/ioutil" "net/http" "net/http/httptest" "net/url" @@ -32,7 +31,7 @@ func (suite *RoundTripperSuite) assertResponse(r *http.Response) { if suite.NotNil(r.Body) { defer r.Body.Close() - b, err := ioutil.ReadAll(r.Body) + b, err := io.ReadAll(r.Body) if suite.NoError(err) { suite.Equal("RoundTripperSuite", string(b)) } diff --git a/retry/client_test.go b/retry/client_test.go index 7229279..cbea9ae 100644 --- a/retry/client_test.go +++ b/retry/client_test.go @@ -6,7 +6,6 @@ import ( "context" "errors" "io" - "io/ioutil" "net/http" "net/http/httptest" "strconv" @@ -86,7 +85,7 @@ func (suite *ClientTestSuite) handler(rw http.ResponseWriter, actual *http.Reque suite.Equal(suite.expected.URL.Path, actual.URL.Path) suite.Equal(int64(len(suite.expectedBody)), actual.ContentLength) - b, err := ioutil.ReadAll(actual.Body) + b, err := io.ReadAll(actual.Body) suite.NoError(err) suite.Equal(suite.expectedBody, string(b)) @@ -105,7 +104,7 @@ func (suite *ClientTestSuite) assertResponse(r *http.Response) { suite.Require().NotNil(r.Body) defer r.Body.Close() - b, err := ioutil.ReadAll(r.Body) + b, err := io.ReadAll(r.Body) suite.NoError(err) suite.Equal("ClientTestSuite", string(b)) } diff --git a/roundtrip/middleware_test.go b/roundtrip/middleware_test.go index 0ac76c3..ef80609 100644 --- a/roundtrip/middleware_test.go +++ b/roundtrip/middleware_test.go @@ -3,7 +3,6 @@ package roundtrip import ( "errors" "io" - "io/ioutil" "net/http" "net/http/httptest" "strconv" @@ -80,7 +79,7 @@ func (suite *ChainTestSuite) assertRequest(expectedOrder []int, transport http.R suite.Require().NoError(err) defer response.Body.Close() - io.Copy(ioutil.Discard, response.Body) + io.Copy(io.Discard, response.Body) suite.Equal(expectedOrder, suite.order, "the decorators did not run in the expected order") suite.Equal(299, response.StatusCode, "the test server was not invoked") }