@@ -20,7 +20,6 @@ import (
20
20
"encoding/xml"
21
21
"errors"
22
22
"io"
23
- "io/ioutil"
24
23
"mime"
25
24
"mime/multipart"
26
25
"net/http"
@@ -165,7 +164,7 @@ func TestBuildRequest_BuildHTTP_Payload(t *testing.T) {
165
164
assert .Equal (t , "world" , req .URL .Query ().Get ("hello" ))
166
165
assert .Equal (t , "/flats/1234/" , req .URL .Path )
167
166
expectedBody , _ := json .Marshal (bd )
168
- actualBody , _ := ioutil .ReadAll (req .Body )
167
+ actualBody , _ := io .ReadAll (req .Body )
169
168
assert .Equal (t , append (expectedBody , '\n' ), actualBody )
170
169
}
171
170
}
@@ -197,7 +196,7 @@ func TestBuildRequest_BuildHTTP_SetsInAuth(t *testing.T) {
197
196
assert .Equal (t , "world" , req .URL .Query ().Get ("hello" ))
198
197
assert .Equal (t , "/flats/1234/" , req .URL .Path )
199
198
expectedBody , _ := json .Marshal (bd )
200
- actualBody , _ := ioutil .ReadAll (req .Body )
199
+ actualBody , _ := io .ReadAll (req .Body )
201
200
assert .Equal (t , append (expectedBody , '\n' ), actualBody )
202
201
}
203
202
}
@@ -224,7 +223,7 @@ func TestBuildRequest_BuildHTTP_XMLPayload(t *testing.T) {
224
223
assert .Equal (t , "world" , req .URL .Query ().Get ("hello" ))
225
224
assert .Equal (t , "/flats/1234/" , req .URL .Path )
226
225
expectedBody , _ := xml .Marshal (bd )
227
- actualBody , _ := ioutil .ReadAll (req .Body )
226
+ actualBody , _ := io .ReadAll (req .Body )
228
227
assert .Equal (t , expectedBody , actualBody )
229
228
}
230
229
}
@@ -247,7 +246,7 @@ func TestBuildRequest_BuildHTTP_TextPayload(t *testing.T) {
247
246
assert .Equal (t , "world" , req .URL .Query ().Get ("hello" ))
248
247
assert .Equal (t , "/flats/1234/" , req .URL .Path )
249
248
expectedBody := []byte (bd )
250
- actualBody , _ := ioutil .ReadAll (req .Body )
249
+ actualBody , _ := io .ReadAll (req .Body )
251
250
assert .Equal (t , expectedBody , actualBody )
252
251
}
253
252
}
@@ -269,7 +268,7 @@ func TestBuildRequest_BuildHTTP_Form(t *testing.T) {
269
268
assert .Equal (t , "world" , req .URL .Query ().Get ("hello" ))
270
269
assert .Equal (t , "/flats/1234/" , req .URL .Path )
271
270
expected := []byte ("something=some+value" )
272
- actual , _ := ioutil .ReadAll (req .Body )
271
+ actual , _ := io .ReadAll (req .Body )
273
272
assert .Equal (t , expected , actual )
274
273
}
275
274
}
@@ -292,7 +291,7 @@ func TestBuildRequest_BuildHTTP_Form_URLEncoded(t *testing.T) {
292
291
assert .Equal (t , "world" , req .URL .Query ().Get ("hello" ))
293
292
assert .Equal (t , "/flats/1234/" , req .URL .Path )
294
293
expected := []byte ("something=some+value" )
295
- actual , _ := ioutil .ReadAll (req .Body )
294
+ actual , _ := io .ReadAll (req .Body )
296
295
assert .Equal (t , expected , actual )
297
296
}
298
297
}
@@ -316,7 +315,7 @@ func TestBuildRequest_BuildHTTP_Form_Content_Length(t *testing.T) {
316
315
assert .Condition (t , func () bool { return req .ContentLength > 0 },
317
316
"ContentLength must great than 0. got %d" , req .ContentLength )
318
317
expected := []byte ("something=some+value" )
319
- actual , _ := ioutil .ReadAll (req .Body )
318
+ actual , _ := io .ReadAll (req .Body )
320
319
assert .Equal (t , expected , actual )
321
320
}
322
321
}
@@ -339,7 +338,7 @@ func TestBuildRequest_BuildHTTP_FormMultipart(t *testing.T) {
339
338
assert .Equal (t , "/flats/1234/" , req .URL .Path )
340
339
expected1 := []byte ("Content-Disposition: form-data; name=\" something\" " )
341
340
expected2 := []byte ("some value" )
342
- actual , _ := ioutil .ReadAll (req .Body )
341
+ actual , _ := io .ReadAll (req .Body )
343
342
actuallines := bytes .Split (actual , []byte ("\r \n " ))
344
343
assert .Equal (t , 6 , len (actuallines ))
345
344
boundary := string (actuallines [0 ])
@@ -371,7 +370,7 @@ func TestBuildRequest_BuildHTTP_FormMultiples(t *testing.T) {
371
370
expected1 := []byte ("Content-Disposition: form-data; name=\" something\" " )
372
371
expected2 := []byte ("some value" )
373
372
expected3 := []byte ("another value" )
374
- actual , _ := ioutil .ReadAll (req .Body )
373
+ actual , _ := io .ReadAll (req .Body )
375
374
actuallines := bytes .Split (actual , []byte ("\r \n " ))
376
375
assert .Equal (t , 10 , len (actuallines ))
377
376
boundary := string (actuallines [0 ])
@@ -388,8 +387,8 @@ func TestBuildRequest_BuildHTTP_FormMultiples(t *testing.T) {
388
387
}
389
388
390
389
func TestBuildRequest_BuildHTTP_Files (t * testing.T ) {
391
- cont , _ := ioutil .ReadFile ("./runtime.go" )
392
- cont2 , _ := ioutil .ReadFile ("./request.go" )
390
+ cont , _ := os .ReadFile ("./runtime.go" )
391
+ cont2 , _ := os .ReadFile ("./request.go" )
393
392
reqWrtr := runtime .ClientRequestWriterFunc (func (req runtime.ClientRequest , reg strfmt.Registry ) error {
394
393
_ = req .SetFormParam ("something" , "some value" )
395
394
_ = req .SetFileParam ("file" , mustGetFile ("./runtime.go" ))
@@ -420,7 +419,7 @@ func TestBuildRequest_BuildHTTP_Files(t *testing.T) {
420
419
mpf , _ := mpff .Open ()
421
420
defer mpf .Close ()
422
421
assert .Equal (t , filename , mpff .Filename )
423
- actual , _ := ioutil .ReadAll (mpf )
422
+ actual , _ := io .ReadAll (mpf )
424
423
assert .Equal (t , content , actual )
425
424
}
426
425
fileverifier ("file" , 0 , "runtime.go" , cont )
@@ -432,8 +431,8 @@ func TestBuildRequest_BuildHTTP_Files(t *testing.T) {
432
431
}
433
432
}
434
433
func TestBuildRequest_BuildHTTP_Files_URLEncoded (t * testing.T ) {
435
- cont , _ := ioutil .ReadFile ("./runtime.go" )
436
- cont2 , _ := ioutil .ReadFile ("./request.go" )
434
+ cont , _ := os .ReadFile ("./runtime.go" )
435
+ cont2 , _ := os .ReadFile ("./request.go" )
437
436
reqWrtr := runtime .ClientRequestWriterFunc (func (req runtime.ClientRequest , reg strfmt.Registry ) error {
438
437
_ = req .SetFormParam ("something" , "some value" )
439
438
_ = req .SetFileParam ("file" , mustGetFile ("./runtime.go" ))
@@ -464,7 +463,7 @@ func TestBuildRequest_BuildHTTP_Files_URLEncoded(t *testing.T) {
464
463
mpf , _ := mpff .Open ()
465
464
defer mpf .Close ()
466
465
assert .Equal (t , filename , mpff .Filename )
467
- actual , _ := ioutil .ReadAll (mpf )
466
+ actual , _ := io .ReadAll (mpf )
468
467
assert .Equal (t , content , actual )
469
468
}
470
469
fileverifier ("file" , 0 , "runtime.go" , cont )
@@ -611,15 +610,15 @@ func TestGetBodyCallsBeforeRoundTrip(t *testing.T) {
611
610
// Read the body once before sending the request
612
611
body , err := req .GetBody ()
613
612
require .NoError (t , err )
614
- bodyContent , err := ioutil .ReadAll (io .Reader (body ))
613
+ bodyContent , err := io .ReadAll (io .Reader (body ))
615
614
require .EqualValues (t , req .ContentLength , len (bodyContent ))
616
615
require .NoError (t , err )
617
616
require .EqualValues (t , "\" test body\" \n " , string (bodyContent ))
618
617
619
618
// Read the body a second time before sending the request
620
619
body , err = req .GetBody ()
621
620
require .NoError (t , err )
622
- bodyContent , err = ioutil .ReadAll (io .Reader (body ))
621
+ bodyContent , err = io .ReadAll (io .Reader (body ))
623
622
require .NoError (t , err )
624
623
require .EqualValues (t , req .ContentLength , len (bodyContent ))
625
624
require .EqualValues (t , "\" test body\" \n " , string (bodyContent ))
0 commit comments