55 "context"
66 "errors"
77 "io"
8- "io/ioutil"
98 "net"
109 "net/http"
1110 "strings"
@@ -70,7 +69,7 @@ func TestDNSClient(t *testing.T) {
7069 require .Equal (t , []byte ("abc" ), buf , "invalid request body" )
7170
7271 resp = & http.Response {
73- Body : ioutil .NopCloser (bytes .NewReader (packMsg (t , expectedMsg ))),
72+ Body : io .NopCloser (bytes .NewReader (packMsg (t , expectedMsg ))),
7473 StatusCode : http .StatusOK ,
7574 }
7675 return
@@ -101,7 +100,7 @@ func TestDNSClientHttpClientError(t *testing.T) {
101100 httpClient := mockHTTPClientFunc (func (req * http.Request ) (resp * http.Response , err error ) {
102101 err = errors .New ("http error" )
103102 resp = & http.Response {
104- Body : ioutil .NopCloser (bytes .NewReader (packMsg (t , newExpectedDNSMsg ()))),
103+ Body : io .NopCloser (bytes .NewReader (packMsg (t , newExpectedDNSMsg ()))),
105104 StatusCode : http .StatusOK ,
106105 }
107106 return
@@ -115,7 +114,7 @@ func TestDNSClientHttpClientError(t *testing.T) {
115114func TestDNSClientHttpStatusError (t * testing.T ) {
116115 httpClient := mockHTTPClientFunc (func (req * http.Request ) (resp * http.Response , err error ) {
117116 resp = & http.Response {
118- Body : ioutil .NopCloser (bytes .NewReader (packMsg (t , newExpectedDNSMsg ()))),
117+ Body : io .NopCloser (bytes .NewReader (packMsg (t , newExpectedDNSMsg ()))),
119118 StatusCode : http .StatusInternalServerError ,
120119 }
121120 return
@@ -147,7 +146,7 @@ func TestDNSClientResponseReadError(t *testing.T) {
147146 err : errors .New ("io error" ),
148147 }
149148 resp = & http.Response {
150- Body : ioutil .NopCloser (reader ),
149+ Body : io .NopCloser (reader ),
151150 StatusCode : http .StatusOK ,
152151 }
153152 return
@@ -161,7 +160,7 @@ func TestDNSClientResponseReadError(t *testing.T) {
161160func TestDNSClientMsgUnpackError (t * testing.T ) {
162161 httpClient := mockHTTPClientFunc (func (req * http.Request ) (resp * http.Response , err error ) {
163162 resp = & http.Response {
164- Body : ioutil .NopCloser (strings .NewReader ("def" )),
163+ Body : io .NopCloser (strings .NewReader ("def" )),
165164 StatusCode : http .StatusOK ,
166165 }
167166 return
@@ -173,15 +172,15 @@ func TestDNSClientMsgUnpackError(t *testing.T) {
173172}
174173
175174func TestDNSClientLargeResponseError (t * testing.T ) {
176- //create large buffer with the correct DNS message at the beginning
175+ // create large buffer with the correct DNS message at the beginning
177176 var buf bytes.Buffer
178177 dnsMsg := packMsg (t , newExpectedDNSMsg ())
179178 buf .Write (dnsMsg )
180179 buf .WriteString (strings .Repeat ("a" , maxDNSMessageSize ))
181180
182181 httpClient := mockHTTPClientFunc (func (req * http.Request ) (resp * http.Response , err error ) {
183182 resp = & http.Response {
184- Body : ioutil .NopCloser (& buf ),
183+ Body : io .NopCloser (& buf ),
185184 StatusCode : http .StatusOK ,
186185 }
187186 return
@@ -289,6 +288,7 @@ func TestLoadBalanceDNSClientMaxFails(t *testing.T) {
289288
290289 lbClient := newLoadBalanceDNSClient (clients ,
291290 withLbPolicy (newSequentialPolicy ()),
291+ withLbRequestTimeout (defaultRequestTimeout ),
292292 withLbMaxFails (tt .maxFails ))
293293
294294 result , err := lbClient .Query (context .Background (), []byte ("abc" ))
0 commit comments