Tests for delete bucket and config functions (#1976)

Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
This commit is contained in:
Daniel Valdivia
2022-05-11 09:39:43 -07:00
committed by GitHub
parent 94b4725e24
commit f409049a51
6 changed files with 206 additions and 33 deletions

View File

@@ -632,7 +632,12 @@ func getDeleteBucketResponse(session *models.Principal, params bucketApi.DeleteB
// defining the client to be used
minioClient := minioClient{client: mClient}
if err := removeBucket(minioClient, bucketName); err != nil {
return ErrorWithContext(ctx, err)
resp := ErrorWithContext(ctx, err)
errResp := minio.ToErrorResponse(err)
if errResp.Code == "NoSuchBucket" {
resp.Code = 404
}
return resp
}
return nil
}

View File

@@ -214,3 +214,33 @@ func Test_isSafeToPreview(t *testing.T) {
})
}
}
func TestRandomCharString(t *testing.T) {
type args struct {
n int
}
tests := []struct {
name string
args args
wantLength int
}{
{
name: "valid string",
args: args{
n: 1,
},
wantLength: 1,
}, {
name: "valid string",
args: args{
n: 64,
},
wantLength: 64,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
assert.Equalf(t, tt.wantLength, len(RandomCharString(tt.args.n)), "RandomCharString(%v)", tt.args.n)
})
}
}