@@ -25,7 +25,6 @@ import (
25
25
"errors"
26
26
"fmt"
27
27
"io"
28
- "io/ioutil"
29
28
"log"
30
29
"net/http"
31
30
"os"
@@ -777,7 +776,7 @@ func TestPutObjectsLegalholdStatus(t *testing.T) {
777
776
778
777
// Get versionID
779
778
listResponse , _ := ListObjects (bucketName , prefix , "true" )
780
- bodyBytes , _ := ioutil .ReadAll (listResponse .Body )
779
+ bodyBytes , _ := io .ReadAll (listResponse .Body )
781
780
listObjs := models.ListObjectsResponse {}
782
781
err := json .Unmarshal (bodyBytes , & listObjs )
783
782
if err != nil {
@@ -1058,7 +1057,7 @@ func TestDeleteObjectsRetentionStatus(t *testing.T) {
1058
1057
1059
1058
// Get versionID
1060
1059
listResponse , _ := ListObjects (bucketName , validPrefix , "true" )
1061
- bodyBytes , _ := ioutil .ReadAll (listResponse .Body )
1060
+ bodyBytes , _ := io .ReadAll (listResponse .Body )
1062
1061
listObjs := models.ListObjectsResponse {}
1063
1062
err := json .Unmarshal (bodyBytes , & listObjs )
1064
1063
if err != nil {
@@ -1226,7 +1225,7 @@ func TestRestoreObjectToASelectedVersion(t *testing.T) {
1226
1225
1227
1226
// 3. Get versionID
1228
1227
listResponse , _ := ListObjects (bucketName , validPrefix , "true" )
1229
- bodyBytes , _ := ioutil .ReadAll (listResponse .Body )
1228
+ bodyBytes , _ := io .ReadAll (listResponse .Body )
1230
1229
listObjs := models.ListObjectsResponse {}
1231
1230
err := json .Unmarshal (bodyBytes , & listObjs )
1232
1231
if err != nil {
@@ -1443,7 +1442,7 @@ func TestPutObjectsRetentionStatus(t *testing.T) {
1443
1442
1444
1443
// Get versionID
1445
1444
listResponse , _ := ListObjects (bucketName , prefix , "true" )
1446
- bodyBytes , _ := ioutil .ReadAll (listResponse .Body )
1445
+ bodyBytes , _ := io .ReadAll (listResponse .Body )
1447
1446
listObjs := models.ListObjectsResponse {}
1448
1447
err := json .Unmarshal (bodyBytes , & listObjs )
1449
1448
if err != nil {
@@ -1776,7 +1775,7 @@ func TestDownloadObject(t *testing.T) {
1776
1775
}
1777
1776
1778
1777
// 4. Verify the file was downloaded
1779
- files , err := ioutil .ReadDir (workingDirectory )
1778
+ files , err := os .ReadDir (workingDirectory )
1780
1779
if err != nil {
1781
1780
log .Fatal (err )
1782
1781
}
@@ -2169,21 +2168,12 @@ func TestListBuckets(t *testing.T) {
2169
2168
// 2. List buckets
2170
2169
listBucketsResponse , listBucketsError := ListBuckets ()
2171
2170
assert .Nil (listBucketsError )
2172
- if listBucketsError != nil {
2173
- log .Println (listBucketsError )
2174
- assert .Fail ("Error listing the buckets" )
2175
- return
2176
- }
2177
-
2171
+ assert .NotNil (listBucketsResponse )
2172
+ assert .NotNil (listBucketsResponse .Body )
2178
2173
// 3. Verify list of buckets
2179
- b , err := io .ReadAll (listBucketsResponse .Body )
2180
- if listBucketsResponse != nil {
2181
- if err != nil {
2182
- log .Fatalln (err )
2183
- }
2184
- assert .Equal (200 , listBucketsResponse .StatusCode ,
2185
- "Status Code is incorrect: " + string (b ))
2186
- }
2174
+ b , _ := io .ReadAll (listBucketsResponse .Body )
2175
+ assert .Equal (200 , listBucketsResponse .StatusCode ,
2176
+ "Status Code is incorrect: " + string (b ))
2187
2177
for i := 1 ; i <= numberOfBuckets ; i ++ {
2188
2178
assert .True (strings .Contains (string (b ),
2189
2179
"testlistbuckets" + strconv .Itoa (i )))
@@ -2215,7 +2205,7 @@ func TestBucketsGet(t *testing.T) {
2215
2205
2216
2206
if response != nil {
2217
2207
assert .Equal (200 , response .StatusCode , "Status Code is incorrect" )
2218
- bodyBytes , _ := ioutil .ReadAll (response .Body )
2208
+ bodyBytes , _ := io .ReadAll (response .Body )
2219
2209
2220
2210
listBuckets := models.ListBucketsResponse {}
2221
2211
err = json .Unmarshal (bodyBytes , & listBuckets )
@@ -2255,7 +2245,7 @@ func TestBucketVersioning(t *testing.T) {
2255
2245
2256
2246
if response != nil {
2257
2247
2258
- bodyBytes , _ := ioutil .ReadAll (response .Body )
2248
+ bodyBytes , _ := io .ReadAll (response .Body )
2259
2249
2260
2250
sessionResponse := models.SessionResponse {}
2261
2251
err = json .Unmarshal (bodyBytes , & sessionResponse )
@@ -2292,7 +2282,7 @@ func TestBucketVersioning(t *testing.T) {
2292
2282
assert .Equal (
2293
2283
200 , getVersioningResult .StatusCode , "Status Code is incorrect" )
2294
2284
}
2295
- bodyBytes , _ := ioutil .ReadAll (getVersioningResult .Body )
2285
+ bodyBytes , _ := io .ReadAll (getVersioningResult .Body )
2296
2286
structBucketRepl := models.BucketVersioningResponse {
2297
2287
ExcludeFolders : false ,
2298
2288
ExcludedPrefixes : nil ,
@@ -2369,7 +2359,7 @@ func TestSetBucketTags(t *testing.T) {
2369
2359
request .Header .Add ("Cookie" , fmt .Sprintf ("token=%s" , token ))
2370
2360
request .Header .Add ("Content-Type" , "application/json" )
2371
2361
2372
- response , err : = client .Do (request )
2362
+ _ , err = client .Do (request )
2373
2363
assert .Nil (err )
2374
2364
if err != nil {
2375
2365
log .Println (err )
@@ -2387,14 +2377,14 @@ func TestSetBucketTags(t *testing.T) {
2387
2377
request .Header .Add ("Cookie" , fmt .Sprintf ("token=%s" , token ))
2388
2378
request .Header .Add ("Content-Type" , "application/json" )
2389
2379
2390
- response , err = client .Do (request )
2380
+ response , err : = client .Do (request )
2391
2381
assert .Nil (err )
2392
2382
if err != nil {
2393
2383
log .Println (err )
2394
2384
return
2395
2385
}
2396
2386
2397
- bodyBytes , _ := ioutil .ReadAll (response .Body )
2387
+ bodyBytes , _ := io .ReadAll (response .Body )
2398
2388
2399
2389
bucket := models.Bucket {}
2400
2390
err = json .Unmarshal (bodyBytes , & bucket )
@@ -2847,7 +2837,7 @@ func TestReplication(t *testing.T) {
2847
2837
}
2848
2838
2849
2839
// 3. Get rule ID and status from response's body
2850
- bodyBytes , _ := ioutil .ReadAll (response .Body )
2840
+ bodyBytes , _ := io .ReadAll (response .Body )
2851
2841
structBucketRepl := models.BucketReplicationResponse {}
2852
2842
err = json .Unmarshal (bodyBytes , & structBucketRepl )
2853
2843
if err != nil {
@@ -2929,7 +2919,7 @@ func TestReplication(t *testing.T) {
2929
2919
}
2930
2920
2931
2921
// 9. Get rule ID and status from response's body
2932
- bodyBytes , _ = ioutil .ReadAll (response .Body )
2922
+ bodyBytes , _ = io .ReadAll (response .Body )
2933
2923
structBucketRepl = models.BucketReplicationResponse {}
2934
2924
err = json .Unmarshal (bodyBytes , & structBucketRepl )
2935
2925
if err != nil {
@@ -2996,7 +2986,7 @@ func TestReturnsTheStatusOfObjectLockingSupportOnTheBucket(t *testing.T) {
2996
2986
}
2997
2987
2998
2988
// 2. Verify the status to be enabled for this bucket
2999
- bodyBytes , _ := ioutil .ReadAll (response .Body )
2989
+ bodyBytes , _ := io .ReadAll (response .Body )
3000
2990
structBucketLocking := models.BucketObLockingResponse {}
3001
2991
err = json .Unmarshal (bodyBytes , & structBucketLocking )
3002
2992
if err != nil {
@@ -3077,7 +3067,7 @@ func TestSetBucketVersioning(t *testing.T) {
3077
3067
assert .Equal (
3078
3068
200 , getVersioningResult .StatusCode , "Status Code is incorrect" )
3079
3069
}
3080
- bodyBytes , _ := ioutil .ReadAll (getVersioningResult .Body )
3070
+ bodyBytes , _ := io .ReadAll (getVersioningResult .Body )
3081
3071
result := models.BucketVersioningResponse {
3082
3072
ExcludeFolders : false ,
3083
3073
ExcludedPrefixes : nil ,
@@ -3160,7 +3150,7 @@ func TestEnableBucketEncryption(t *testing.T) {
3160
3150
assert .Equal (
3161
3151
200 , resp .StatusCode , "Status Code is incorrect" )
3162
3152
}
3163
- bodyBytes , _ := ioutil .ReadAll (resp .Body )
3153
+ bodyBytes , _ := io .ReadAll (resp .Body )
3164
3154
result := models.BucketEncryptionInfo {}
3165
3155
err = json .Unmarshal (bodyBytes , & result )
3166
3156
if err != nil {
@@ -3192,7 +3182,7 @@ func TestEnableBucketEncryption(t *testing.T) {
3192
3182
assert .Equal (
3193
3183
404 , resp .StatusCode , "Status Code is incorrect" )
3194
3184
}
3195
- bodyBytes , _ = ioutil .ReadAll (resp .Body )
3185
+ bodyBytes , _ = io .ReadAll (resp .Body )
3196
3186
result2 := models.Error {}
3197
3187
err = json .Unmarshal (bodyBytes , & result2 )
3198
3188
if err != nil {
@@ -3437,7 +3427,7 @@ func TestBucketLifeCycle(t *testing.T) {
3437
3427
assert .Equal (
3438
3428
200 , resp .StatusCode , "Status Code is incorrect" )
3439
3429
}
3440
- bodyBytes , _ := ioutil .ReadAll (resp .Body )
3430
+ bodyBytes , _ := io .ReadAll (resp .Body )
3441
3431
result := models.BucketLifecycleResponse {}
3442
3432
err = json .Unmarshal (bodyBytes , & result )
3443
3433
if err != nil {
@@ -3483,7 +3473,7 @@ func TestBucketLifeCycle(t *testing.T) {
3483
3473
assert .Equal (
3484
3474
200 , resp .StatusCode , "Status Code is incorrect" )
3485
3475
}
3486
- bodyBytes , _ = ioutil .ReadAll (resp .Body )
3476
+ bodyBytes , _ = io .ReadAll (resp .Body )
3487
3477
result = models.BucketLifecycleResponse {}
3488
3478
err = json .Unmarshal (bodyBytes , & result )
3489
3479
if err != nil {
@@ -3643,7 +3633,7 @@ func TestAccessRule(t *testing.T) {
3643
3633
assert .Equal (
3644
3634
200 , resp .StatusCode , "Status Code is incorrect" )
3645
3635
}
3646
- bodyBytes , _ := ioutil .ReadAll (resp .Body )
3636
+ bodyBytes , _ := io .ReadAll (resp .Body )
3647
3637
result := models.ListAccessRulesResponse {}
3648
3638
err = json .Unmarshal (bodyBytes , & result )
3649
3639
if err != nil {
@@ -3681,7 +3671,7 @@ func TestAccessRule(t *testing.T) {
3681
3671
assert .Equal (
3682
3672
200 , resp .StatusCode , "Status Code is incorrect" )
3683
3673
}
3684
- bodyBytes , _ = ioutil .ReadAll (resp .Body )
3674
+ bodyBytes , _ = io .ReadAll (resp .Body )
3685
3675
result = models.ListAccessRulesResponse {}
3686
3676
err = json .Unmarshal (bodyBytes , & result )
3687
3677
if err != nil {
@@ -3950,21 +3940,13 @@ func TestDeleteRemoteBucket(t *testing.T) {
3950
3940
// 3. Get ARN
3951
3941
resp , err = GetRemoteBucketARN (sourceBucket )
3952
3942
assert .Nil (err )
3953
- if err != nil {
3954
- log .Println (err )
3955
- return
3956
- }
3957
- bodyBytes , _ := ioutil .ReadAll (resp .Body )
3943
+ assert .NotNil (resp )
3944
+ assert .NotNil (resp .Body )
3945
+ bodyBytes , _ := io .ReadAll (resp .Body )
3958
3946
remoteBucket := models.RemoteBucket {}
3959
3947
err = json .Unmarshal (bodyBytes , & remoteBucket )
3960
- if err != nil {
3961
- log .Println (err )
3962
- assert .Nil (err )
3963
- }
3964
- if resp != nil {
3965
- assert .Equal (
3966
- 200 , resp .StatusCode , inspectHTTPResponse (resp ))
3967
- }
3948
+ assert .Nil (err )
3949
+ assert .Equal (200 , resp .StatusCode , inspectHTTPResponse (resp ))
3968
3950
3969
3951
// 4. Delete Remote Bucket
3970
3952
if remoteBucket .RemoteARN != nil {
0 commit comments