1
0
mirror of synced 2024-11-22 13:06:05 +03:00

fix undefined package error

This commit is contained in:
Ruslan Efanov 2022-10-28 10:05:11 +03:00
parent bb57d2c2e8
commit a321456c78
2 changed files with 5 additions and 4 deletions

View File

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"errors" "errors"
"fmt" "fmt"
"io" "io/ioutil"
"net/http" "net/http"
"net/url" "net/url"
"testing" "testing"
@ -39,7 +39,7 @@ func TestNewApiClientError(t *testing.T) {
func TestNewServerError(t *testing.T) { func TestNewServerError(t *testing.T) {
body := []byte(`{"errors" : ["Something went wrong"]}`) body := []byte(`{"errors" : ["Something went wrong"]}`)
response := new(http.Response) response := new(http.Response)
response.Body = io.NopCloser(bytes.NewReader(body)) response.Body = ioutil.NopCloser(bytes.NewReader(body))
serverErr := NewServerError(response) serverErr := NewServerError(response)
assert.IsType(t, new(HTTPClientError), serverErr) assert.IsType(t, new(HTTPClientError), serverErr)
@ -54,7 +54,7 @@ func TestNewServerError(t *testing.T) {
body = []byte(`{"invalid_json"`) body = []byte(`{"invalid_json"`)
response = new(http.Response) response = new(http.Response)
response.Body = io.NopCloser(bytes.NewReader(body)) response.Body = ioutil.NopCloser(bytes.NewReader(body))
serverErr = NewServerError(response) serverErr = NewServerError(response)
assert.IsType(t, new(HTTPClientError), serverErr) assert.IsType(t, new(HTTPClientError), serverErr)

View File

@ -2,6 +2,7 @@ package v1
import ( import (
"io" "io"
"io/ioutil"
"net/http" "net/http"
) )
@ -11,7 +12,7 @@ func buildLimitedRawResponse(resp *http.Response) ([]byte, error) {
defer resp.Body.Close() defer resp.Body.Close()
limitReader := io.LimitReader(resp.Body, MB) limitReader := io.LimitReader(resp.Body, MB)
body, err := io.ReadAll(limitReader) body, err := ioutil.ReadAll(limitReader)
if err != nil { if err != nil {
return body, err return body, err