@@ -25,7 +25,6 @@ import (
2525 "errors"
2626 "fmt"
2727 "io"
28- "io/ioutil"
2928 "log"
3029 "net/http"
3130 "os"
@@ -777,7 +776,7 @@ func TestPutObjectsLegalholdStatus(t *testing.T) {
777776
778777 // Get versionID
779778 listResponse , _ := ListObjects (bucketName , prefix , "true" )
780- bodyBytes , _ := ioutil .ReadAll (listResponse .Body )
779+ bodyBytes , _ := io .ReadAll (listResponse .Body )
781780 listObjs := models.ListObjectsResponse {}
782781 err := json .Unmarshal (bodyBytes , & listObjs )
783782 if err != nil {
@@ -1058,7 +1057,7 @@ func TestDeleteObjectsRetentionStatus(t *testing.T) {
10581057
10591058 // Get versionID
10601059 listResponse , _ := ListObjects (bucketName , validPrefix , "true" )
1061- bodyBytes , _ := ioutil .ReadAll (listResponse .Body )
1060+ bodyBytes , _ := io .ReadAll (listResponse .Body )
10621061 listObjs := models.ListObjectsResponse {}
10631062 err := json .Unmarshal (bodyBytes , & listObjs )
10641063 if err != nil {
@@ -1226,7 +1225,7 @@ func TestRestoreObjectToASelectedVersion(t *testing.T) {
12261225
12271226 // 3. Get versionID
12281227 listResponse , _ := ListObjects (bucketName , validPrefix , "true" )
1229- bodyBytes , _ := ioutil .ReadAll (listResponse .Body )
1228+ bodyBytes , _ := io .ReadAll (listResponse .Body )
12301229 listObjs := models.ListObjectsResponse {}
12311230 err := json .Unmarshal (bodyBytes , & listObjs )
12321231 if err != nil {
@@ -1443,7 +1442,7 @@ func TestPutObjectsRetentionStatus(t *testing.T) {
14431442
14441443 // Get versionID
14451444 listResponse , _ := ListObjects (bucketName , prefix , "true" )
1446- bodyBytes , _ := ioutil .ReadAll (listResponse .Body )
1445+ bodyBytes , _ := io .ReadAll (listResponse .Body )
14471446 listObjs := models.ListObjectsResponse {}
14481447 err := json .Unmarshal (bodyBytes , & listObjs )
14491448 if err != nil {
@@ -1776,7 +1775,7 @@ func TestDownloadObject(t *testing.T) {
17761775 }
17771776
17781777 // 4. Verify the file was downloaded
1779- files , err := ioutil .ReadDir (workingDirectory )
1778+ files , err := os .ReadDir (workingDirectory )
17801779 if err != nil {
17811780 log .Fatal (err )
17821781 }
@@ -2169,21 +2168,12 @@ func TestListBuckets(t *testing.T) {
21692168 // 2. List buckets
21702169 listBucketsResponse , listBucketsError := ListBuckets ()
21712170 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 )
21782173 // 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 ))
21872177 for i := 1 ; i <= numberOfBuckets ; i ++ {
21882178 assert .True (strings .Contains (string (b ),
21892179 "testlistbuckets" + strconv .Itoa (i )))
@@ -2215,7 +2205,7 @@ func TestBucketsGet(t *testing.T) {
22152205
22162206 if response != nil {
22172207 assert .Equal (200 , response .StatusCode , "Status Code is incorrect" )
2218- bodyBytes , _ := ioutil .ReadAll (response .Body )
2208+ bodyBytes , _ := io .ReadAll (response .Body )
22192209
22202210 listBuckets := models.ListBucketsResponse {}
22212211 err = json .Unmarshal (bodyBytes , & listBuckets )
@@ -2255,7 +2245,7 @@ func TestBucketVersioning(t *testing.T) {
22552245
22562246 if response != nil {
22572247
2258- bodyBytes , _ := ioutil .ReadAll (response .Body )
2248+ bodyBytes , _ := io .ReadAll (response .Body )
22592249
22602250 sessionResponse := models.SessionResponse {}
22612251 err = json .Unmarshal (bodyBytes , & sessionResponse )
@@ -2292,7 +2282,7 @@ func TestBucketVersioning(t *testing.T) {
22922282 assert .Equal (
22932283 200 , getVersioningResult .StatusCode , "Status Code is incorrect" )
22942284 }
2295- bodyBytes , _ := ioutil .ReadAll (getVersioningResult .Body )
2285+ bodyBytes , _ := io .ReadAll (getVersioningResult .Body )
22962286 structBucketRepl := models.BucketVersioningResponse {
22972287 ExcludeFolders : false ,
22982288 ExcludedPrefixes : nil ,
@@ -2369,7 +2359,7 @@ func TestSetBucketTags(t *testing.T) {
23692359 request .Header .Add ("Cookie" , fmt .Sprintf ("token=%s" , token ))
23702360 request .Header .Add ("Content-Type" , "application/json" )
23712361
2372- response , err : = client .Do (request )
2362+ _ , err = client .Do (request )
23732363 assert .Nil (err )
23742364 if err != nil {
23752365 log .Println (err )
@@ -2387,14 +2377,14 @@ func TestSetBucketTags(t *testing.T) {
23872377 request .Header .Add ("Cookie" , fmt .Sprintf ("token=%s" , token ))
23882378 request .Header .Add ("Content-Type" , "application/json" )
23892379
2390- response , err = client .Do (request )
2380+ response , err : = client .Do (request )
23912381 assert .Nil (err )
23922382 if err != nil {
23932383 log .Println (err )
23942384 return
23952385 }
23962386
2397- bodyBytes , _ := ioutil .ReadAll (response .Body )
2387+ bodyBytes , _ := io .ReadAll (response .Body )
23982388
23992389 bucket := models.Bucket {}
24002390 err = json .Unmarshal (bodyBytes , & bucket )
@@ -2847,7 +2837,7 @@ func TestReplication(t *testing.T) {
28472837 }
28482838
28492839 // 3. Get rule ID and status from response's body
2850- bodyBytes , _ := ioutil .ReadAll (response .Body )
2840+ bodyBytes , _ := io .ReadAll (response .Body )
28512841 structBucketRepl := models.BucketReplicationResponse {}
28522842 err = json .Unmarshal (bodyBytes , & structBucketRepl )
28532843 if err != nil {
@@ -2929,7 +2919,7 @@ func TestReplication(t *testing.T) {
29292919 }
29302920
29312921 // 9. Get rule ID and status from response's body
2932- bodyBytes , _ = ioutil .ReadAll (response .Body )
2922+ bodyBytes , _ = io .ReadAll (response .Body )
29332923 structBucketRepl = models.BucketReplicationResponse {}
29342924 err = json .Unmarshal (bodyBytes , & structBucketRepl )
29352925 if err != nil {
@@ -2996,7 +2986,7 @@ func TestReturnsTheStatusOfObjectLockingSupportOnTheBucket(t *testing.T) {
29962986 }
29972987
29982988 // 2. Verify the status to be enabled for this bucket
2999- bodyBytes , _ := ioutil .ReadAll (response .Body )
2989+ bodyBytes , _ := io .ReadAll (response .Body )
30002990 structBucketLocking := models.BucketObLockingResponse {}
30012991 err = json .Unmarshal (bodyBytes , & structBucketLocking )
30022992 if err != nil {
@@ -3077,7 +3067,7 @@ func TestSetBucketVersioning(t *testing.T) {
30773067 assert .Equal (
30783068 200 , getVersioningResult .StatusCode , "Status Code is incorrect" )
30793069 }
3080- bodyBytes , _ := ioutil .ReadAll (getVersioningResult .Body )
3070+ bodyBytes , _ := io .ReadAll (getVersioningResult .Body )
30813071 result := models.BucketVersioningResponse {
30823072 ExcludeFolders : false ,
30833073 ExcludedPrefixes : nil ,
@@ -3160,7 +3150,7 @@ func TestEnableBucketEncryption(t *testing.T) {
31603150 assert .Equal (
31613151 200 , resp .StatusCode , "Status Code is incorrect" )
31623152 }
3163- bodyBytes , _ := ioutil .ReadAll (resp .Body )
3153+ bodyBytes , _ := io .ReadAll (resp .Body )
31643154 result := models.BucketEncryptionInfo {}
31653155 err = json .Unmarshal (bodyBytes , & result )
31663156 if err != nil {
@@ -3192,7 +3182,7 @@ func TestEnableBucketEncryption(t *testing.T) {
31923182 assert .Equal (
31933183 404 , resp .StatusCode , "Status Code is incorrect" )
31943184 }
3195- bodyBytes , _ = ioutil .ReadAll (resp .Body )
3185+ bodyBytes , _ = io .ReadAll (resp .Body )
31963186 result2 := models.Error {}
31973187 err = json .Unmarshal (bodyBytes , & result2 )
31983188 if err != nil {
@@ -3437,7 +3427,7 @@ func TestBucketLifeCycle(t *testing.T) {
34373427 assert .Equal (
34383428 200 , resp .StatusCode , "Status Code is incorrect" )
34393429 }
3440- bodyBytes , _ := ioutil .ReadAll (resp .Body )
3430+ bodyBytes , _ := io .ReadAll (resp .Body )
34413431 result := models.BucketLifecycleResponse {}
34423432 err = json .Unmarshal (bodyBytes , & result )
34433433 if err != nil {
@@ -3483,7 +3473,7 @@ func TestBucketLifeCycle(t *testing.T) {
34833473 assert .Equal (
34843474 200 , resp .StatusCode , "Status Code is incorrect" )
34853475 }
3486- bodyBytes , _ = ioutil .ReadAll (resp .Body )
3476+ bodyBytes , _ = io .ReadAll (resp .Body )
34873477 result = models.BucketLifecycleResponse {}
34883478 err = json .Unmarshal (bodyBytes , & result )
34893479 if err != nil {
@@ -3643,7 +3633,7 @@ func TestAccessRule(t *testing.T) {
36433633 assert .Equal (
36443634 200 , resp .StatusCode , "Status Code is incorrect" )
36453635 }
3646- bodyBytes , _ := ioutil .ReadAll (resp .Body )
3636+ bodyBytes , _ := io .ReadAll (resp .Body )
36473637 result := models.ListAccessRulesResponse {}
36483638 err = json .Unmarshal (bodyBytes , & result )
36493639 if err != nil {
@@ -3681,7 +3671,7 @@ func TestAccessRule(t *testing.T) {
36813671 assert .Equal (
36823672 200 , resp .StatusCode , "Status Code is incorrect" )
36833673 }
3684- bodyBytes , _ = ioutil .ReadAll (resp .Body )
3674+ bodyBytes , _ = io .ReadAll (resp .Body )
36853675 result = models.ListAccessRulesResponse {}
36863676 err = json .Unmarshal (bodyBytes , & result )
36873677 if err != nil {
@@ -3950,21 +3940,13 @@ func TestDeleteRemoteBucket(t *testing.T) {
39503940 // 3. Get ARN
39513941 resp , err = GetRemoteBucketARN (sourceBucket )
39523942 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 )
39583946 remoteBucket := models.RemoteBucket {}
39593947 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 ))
39683950
39693951 // 4. Delete Remote Bucket
39703952 if remoteBucket .RemoteARN != nil {
0 commit comments