fix undefined package error
This commit is contained in:
parent
bb57d2c2e8
commit
a321456c78
@ -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)
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user