Tests for delete bucket and config functions (#1976)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user