5
5
"context"
6
6
"errors"
7
7
"io"
8
- "io/ioutil"
9
8
"net"
10
9
"net/http"
11
10
"strings"
@@ -70,7 +69,7 @@ func TestDNSClient(t *testing.T) {
70
69
require .Equal (t , []byte ("abc" ), buf , "invalid request body" )
71
70
72
71
resp = & http.Response {
73
- Body : ioutil .NopCloser (bytes .NewReader (packMsg (t , expectedMsg ))),
72
+ Body : io .NopCloser (bytes .NewReader (packMsg (t , expectedMsg ))),
74
73
StatusCode : http .StatusOK ,
75
74
}
76
75
return
@@ -101,7 +100,7 @@ func TestDNSClientHttpClientError(t *testing.T) {
101
100
httpClient := mockHTTPClientFunc (func (req * http.Request ) (resp * http.Response , err error ) {
102
101
err = errors .New ("http error" )
103
102
resp = & http.Response {
104
- Body : ioutil .NopCloser (bytes .NewReader (packMsg (t , newExpectedDNSMsg ()))),
103
+ Body : io .NopCloser (bytes .NewReader (packMsg (t , newExpectedDNSMsg ()))),
105
104
StatusCode : http .StatusOK ,
106
105
}
107
106
return
@@ -115,7 +114,7 @@ func TestDNSClientHttpClientError(t *testing.T) {
115
114
func TestDNSClientHttpStatusError (t * testing.T ) {
116
115
httpClient := mockHTTPClientFunc (func (req * http.Request ) (resp * http.Response , err error ) {
117
116
resp = & http.Response {
118
- Body : ioutil .NopCloser (bytes .NewReader (packMsg (t , newExpectedDNSMsg ()))),
117
+ Body : io .NopCloser (bytes .NewReader (packMsg (t , newExpectedDNSMsg ()))),
119
118
StatusCode : http .StatusInternalServerError ,
120
119
}
121
120
return
@@ -147,7 +146,7 @@ func TestDNSClientResponseReadError(t *testing.T) {
147
146
err : errors .New ("io error" ),
148
147
}
149
148
resp = & http.Response {
150
- Body : ioutil .NopCloser (reader ),
149
+ Body : io .NopCloser (reader ),
151
150
StatusCode : http .StatusOK ,
152
151
}
153
152
return
@@ -161,7 +160,7 @@ func TestDNSClientResponseReadError(t *testing.T) {
161
160
func TestDNSClientMsgUnpackError (t * testing.T ) {
162
161
httpClient := mockHTTPClientFunc (func (req * http.Request ) (resp * http.Response , err error ) {
163
162
resp = & http.Response {
164
- Body : ioutil .NopCloser (strings .NewReader ("def" )),
163
+ Body : io .NopCloser (strings .NewReader ("def" )),
165
164
StatusCode : http .StatusOK ,
166
165
}
167
166
return
@@ -173,15 +172,15 @@ func TestDNSClientMsgUnpackError(t *testing.T) {
173
172
}
174
173
175
174
func 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
177
176
var buf bytes.Buffer
178
177
dnsMsg := packMsg (t , newExpectedDNSMsg ())
179
178
buf .Write (dnsMsg )
180
179
buf .WriteString (strings .Repeat ("a" , maxDNSMessageSize ))
181
180
182
181
httpClient := mockHTTPClientFunc (func (req * http.Request ) (resp * http.Response , err error ) {
183
182
resp = & http.Response {
184
- Body : ioutil .NopCloser (& buf ),
183
+ Body : io .NopCloser (& buf ),
185
184
StatusCode : http .StatusOK ,
186
185
}
187
186
return
@@ -289,6 +288,7 @@ func TestLoadBalanceDNSClientMaxFails(t *testing.T) {
289
288
290
289
lbClient := newLoadBalanceDNSClient (clients ,
291
290
withLbPolicy (newSequentialPolicy ()),
291
+ withLbRequestTimeout (defaultRequestTimeout ),
292
292
withLbMaxFails (tt .maxFails ))
293
293
294
294
result , err := lbClient .Query (context .Background (), []byte ("abc" ))
0 commit comments