@ -5,7 +5,7 @@ import (
"context"
"crypto/tls"
"encoding/json"
"io/ioutil "
"io"
nethttp "net/http"
"testing"
"time"
@ -135,7 +135,7 @@ func TestWithDiscovery(t *testing.T) {
func TestDefaultRequestEncoder ( t * testing . T ) {
req1 := & nethttp . Request {
Header : make ( nethttp . Header ) ,
Body : ioutil . NopCloser ( bytes . NewBufferString ( "{\"a\":\"1\", \"b\": 2}" ) ) ,
Body : io . NopCloser ( bytes . NewBufferString ( "{\"a\":\"1\", \"b\": 2}" ) ) ,
}
req1 . Header . Set ( "Content-Type" , "application/xml" )
@ -158,7 +158,7 @@ func TestDefaultResponseDecoder(t *testing.T) {
resp1 := & nethttp . Response {
Header : make ( nethttp . Header ) ,
StatusCode : 200 ,
Body : ioutil . NopCloser ( bytes . NewBufferString ( "{\"a\":\"1\", \"b\": 2}" ) ) ,
Body : io . NopCloser ( bytes . NewBufferString ( "{\"a\":\"1\", \"b\": 2}" ) ) ,
}
v1 := & struct {
A string ` json:"a" `
@ -172,7 +172,7 @@ func TestDefaultResponseDecoder(t *testing.T) {
resp2 := & nethttp . Response {
Header : make ( nethttp . Header ) ,
StatusCode : 200 ,
Body : ioutil . NopCloser ( bytes . NewBufferString ( "{badjson}" ) ) ,
Body : io . NopCloser ( bytes . NewBufferString ( "{badjson}" ) ) ,
}
v2 := & struct {
A string ` json:"a" `
@ -191,14 +191,14 @@ func TestDefaultErrorDecoder(t *testing.T) {
resp1 := & nethttp . Response {
Header : make ( nethttp . Header ) ,
StatusCode : 300 ,
Body : ioutil . NopCloser ( bytes . NewBufferString ( "{\"foo\":\"bar\"}" ) ) ,
Body : io . NopCloser ( bytes . NewBufferString ( "{\"foo\":\"bar\"}" ) ) ,
}
assert . Error ( t , DefaultErrorDecoder ( context . TODO ( ) , resp1 ) )
resp2 := & nethttp . Response {
Header : make ( nethttp . Header ) ,
StatusCode : 500 ,
Body : ioutil . NopCloser ( bytes . NewBufferString ( "{\"code\":54321, \"message\": \"hi\", \"reason\": \"FOO\"}" ) ) ,
Body : io . NopCloser ( bytes . NewBufferString ( "{\"code\":54321, \"message\": \"hi\", \"reason\": \"FOO\"}" ) ) ,
}
err2 := DefaultErrorDecoder ( context . TODO ( ) , resp2 )
assert . Error ( t , err2 )