mirror of
https://github.com/minio/minio.git
synced 2025-04-19 18:17:30 -04:00
tests: Fix ListMultipartUploadsHandler tests. (#2705)
This commit is contained in:
parent
03430d0db8
commit
a1ff351f21
@ -48,7 +48,6 @@ const (
|
|||||||
ErrNone APIErrorCode = iota
|
ErrNone APIErrorCode = iota
|
||||||
ErrAccessDenied
|
ErrAccessDenied
|
||||||
ErrBadDigest
|
ErrBadDigest
|
||||||
ErrBucketAlreadyExists
|
|
||||||
ErrEntityTooSmall
|
ErrEntityTooSmall
|
||||||
ErrEntityTooLarge
|
ErrEntityTooLarge
|
||||||
ErrIncompleteBody
|
ErrIncompleteBody
|
||||||
@ -193,11 +192,6 @@ var errorCodeResponse = map[APIErrorCode]APIError{
|
|||||||
Description: "The Content-Md5 you specified did not match what we received.",
|
Description: "The Content-Md5 you specified did not match what we received.",
|
||||||
HTTPStatusCode: http.StatusBadRequest,
|
HTTPStatusCode: http.StatusBadRequest,
|
||||||
},
|
},
|
||||||
ErrBucketAlreadyExists: {
|
|
||||||
Code: "BucketAlreadyExists",
|
|
||||||
Description: "The requested bucket name is not available.",
|
|
||||||
HTTPStatusCode: http.StatusConflict,
|
|
||||||
},
|
|
||||||
ErrEntityTooSmall: {
|
ErrEntityTooSmall: {
|
||||||
Code: "EntityTooSmall",
|
Code: "EntityTooSmall",
|
||||||
Description: "Your proposed upload is smaller than the minimum allowed object size.",
|
Description: "Your proposed upload is smaller than the minimum allowed object size.",
|
||||||
@ -613,6 +607,14 @@ func toAPIErrorCode(err error) (apiErr APIErrorCode) {
|
|||||||
apiErr = ErrWriteQuorum
|
apiErr = ErrWriteQuorum
|
||||||
case InsufficientReadQuorum:
|
case InsufficientReadQuorum:
|
||||||
apiErr = ErrReadQuorum
|
apiErr = ErrReadQuorum
|
||||||
|
case UnsupportedDelimiter:
|
||||||
|
apiErr = ErrNotImplemented
|
||||||
|
case InvalidMarkerPrefixCombination:
|
||||||
|
apiErr = ErrNotImplemented
|
||||||
|
case InvalidUploadIDKeyCombination:
|
||||||
|
apiErr = ErrNotImplemented
|
||||||
|
case MalformedUploadID:
|
||||||
|
apiErr = ErrNoSuchUpload
|
||||||
case PartTooSmall:
|
case PartTooSmall:
|
||||||
apiErr = ErrEntityTooSmall
|
apiErr = ErrEntityTooSmall
|
||||||
default:
|
default:
|
||||||
|
135
cmd/api-errors_test.go
Normal file
135
cmd/api-errors_test.go
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
/*
|
||||||
|
* Minio Cloud Storage, (C) 2016 Minio, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package cmd
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestAPIErrCode(t *testing.T) {
|
||||||
|
testCases := []struct {
|
||||||
|
err error
|
||||||
|
errCode APIErrorCode
|
||||||
|
}{
|
||||||
|
// Valid cases.
|
||||||
|
{
|
||||||
|
BadDigest{},
|
||||||
|
ErrBadDigest,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
IncompleteBody{},
|
||||||
|
ErrIncompleteBody,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ObjectExistsAsDirectory{},
|
||||||
|
ErrObjectExistsAsDirectory,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
BucketNameInvalid{},
|
||||||
|
ErrInvalidBucketName,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
BucketExists{},
|
||||||
|
ErrBucketAlreadyOwnedByYou,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ObjectNotFound{},
|
||||||
|
ErrNoSuchKey,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ObjectNameInvalid{},
|
||||||
|
ErrInvalidObjectName,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
InvalidUploadID{},
|
||||||
|
ErrNoSuchUpload,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
InvalidPart{},
|
||||||
|
ErrInvalidPart,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
InsufficientReadQuorum{},
|
||||||
|
ErrReadQuorum,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
InsufficientWriteQuorum{},
|
||||||
|
ErrWriteQuorum,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
UnsupportedDelimiter{},
|
||||||
|
ErrNotImplemented,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
InvalidMarkerPrefixCombination{},
|
||||||
|
ErrNotImplemented,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
InvalidUploadIDKeyCombination{},
|
||||||
|
ErrNotImplemented,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MalformedUploadID{},
|
||||||
|
ErrNoSuchUpload,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
PartTooSmall{},
|
||||||
|
ErrEntityTooSmall,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
BucketNotEmpty{},
|
||||||
|
ErrBucketNotEmpty,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
BucketNotFound{},
|
||||||
|
ErrNoSuchBucket,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
StorageFull{},
|
||||||
|
ErrStorageFull,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
errSignatureMismatch,
|
||||||
|
ErrSignatureDoesNotMatch,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
errContentSHA256Mismatch,
|
||||||
|
ErrContentSHA256Mismatch,
|
||||||
|
}, // End of all valid cases.
|
||||||
|
|
||||||
|
// Case where err is nil.
|
||||||
|
{
|
||||||
|
nil,
|
||||||
|
ErrNone,
|
||||||
|
},
|
||||||
|
|
||||||
|
// Case where err type is unknown.
|
||||||
|
{
|
||||||
|
errors.New("Custom error"),
|
||||||
|
ErrInternalError,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate all the errors with their API error codes.
|
||||||
|
for i, testCase := range testCases {
|
||||||
|
errCode := toAPIErrorCode(testCase.err)
|
||||||
|
if errCode != testCase.errCode {
|
||||||
|
t.Errorf("Test %d: Expected error code %d, got %d", i+1, testCase.errCode, errCode)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -202,7 +202,7 @@ func testHeadBucketHandler(obj ObjectLayer, instanceType string, t TestErrHandle
|
|||||||
|
|
||||||
// Wrapper for calling TestListMultipartUploadsHandler tests for both XL multiple disks and single node setup.
|
// Wrapper for calling TestListMultipartUploadsHandler tests for both XL multiple disks and single node setup.
|
||||||
func TestListMultipartUploadsHandler(t *testing.T) {
|
func TestListMultipartUploadsHandler(t *testing.T) {
|
||||||
ExecObjectLayerTest(t, testListMultipartUploads)
|
ExecObjectLayerTest(t, testListMultipartUploadsHandler)
|
||||||
}
|
}
|
||||||
|
|
||||||
// testListMultipartUploadsHandler - Tests validate listing of multipart uploads.
|
// testListMultipartUploadsHandler - Tests validate listing of multipart uploads.
|
||||||
@ -253,12 +253,12 @@ func testListMultipartUploadsHandler(obj ObjectLayer, instanceType string, t Tes
|
|||||||
// 2 - bucket not found.
|
// 2 - bucket not found.
|
||||||
{"volatile-bucket-1", "", "", "", "", "0", http.StatusNotFound, false},
|
{"volatile-bucket-1", "", "", "", "", "0", http.StatusNotFound, false},
|
||||||
// 3 - invalid delimiter.
|
// 3 - invalid delimiter.
|
||||||
{bucketName, "", "", "", "-", "0", http.StatusBadRequest, false},
|
{bucketName, "", "", "", "-", "0", http.StatusNotImplemented, false},
|
||||||
// 4 - invalid prefix and marker combination.
|
// 4 - invalid prefix and marker combination.
|
||||||
{bucketName, "asia", "europe-object", "", "", "0", http.StatusNotImplemented, false},
|
{bucketName, "asia", "europe-object", "", "", "0", http.StatusNotImplemented, false},
|
||||||
// 5 - invalid upload id and marker combination.
|
// 5 - invalid upload id and marker combination.
|
||||||
{bucketName, "asia", "asia/europe/", "abc", "", "0", http.StatusBadRequest, false},
|
{bucketName, "asia", "asia/europe/", "abc", "", "0", http.StatusNotImplemented, false},
|
||||||
// 6 - invalid max upload id.
|
// 6 - invalid max uploads.
|
||||||
{bucketName, "", "", "", "", "-1", http.StatusBadRequest, false},
|
{bucketName, "", "", "", "", "-1", http.StatusBadRequest, false},
|
||||||
// 7 - good case delimiter.
|
// 7 - good case delimiter.
|
||||||
{bucketName, "", "", "", "/", "100", http.StatusOK, true},
|
{bucketName, "", "", "", "/", "100", http.StatusOK, true},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user