rename completeMultipartMD5() into getCompleteMultipartMD5(). (#3051)

This commit is contained in:
Bala FA 2016-10-24 13:56:13 -07:00 committed by Harshavardhana
parent 7fc598b73f
commit 36639b65a9
6 changed files with 37 additions and 5 deletions

View File

@ -643,7 +643,7 @@ func (fs fsObjects) CompleteMultipartUpload(bucket string, object string, upload
defer nsMutex.Unlock(minioMetaBucket, fsAppendMetaPath, opsID)
// Calculate s3 compatible md5sum for complete multipart.
s3MD5, err := completeMultipartMD5(parts...)
s3MD5, err := getCompleteMultipartMD5(parts...)
if err != nil {
return "", err
}

View File

@ -1864,7 +1864,7 @@ func testObjectCompleteMultipartUpload(obj ObjectLayer, instanceType string, t T
},
},
}
s3MD5, err := completeMultipartMD5(inputParts[3].parts...)
s3MD5, err := getCompleteMultipartMD5(inputParts[3].parts...)
if err != nil {
t.Fatalf("Obtaining S3MD5 failed")
}

View File

@ -1245,7 +1245,7 @@ func testAPICompleteMultipartHandler(obj ObjectLayer, instanceType, bucketName s
}
// on successfull complete multipart operation the s3MD5 for the parts uploaded will be returned.
s3MD5, err := completeMultipartMD5(inputParts[3].parts...)
s3MD5, err := getCompleteMultipartMD5(inputParts[3].parts...)
if err != nil {
t.Fatalf("Obtaining S3MD5 failed")
}

View File

@ -141,7 +141,7 @@ func getUUID() (uuidStr string) {
}
// Create an s3 compatible MD5sum for complete multipart transaction.
func completeMultipartMD5(parts ...completePart) (string, error) {
func getCompleteMultipartMD5(parts ...completePart) (string, error) {
var finalMD5Bytes []byte
for _, part := range parts {
md5Bytes, err := hex.DecodeString(part.ETag)

View File

@ -136,3 +136,35 @@ func TestLimitReader(t *testing.T) {
}
}
}
// Tests getCompleteMultipartMD5
func TestGetCompleteMultipartMD5(t *testing.T) {
testCases := []struct {
parts []completePart
expectedResult string
expectedErr string
}{
// Wrong MD5 hash string
{[]completePart{{ETag: "wrong-md5-hash-string"}}, "", "encoding/hex: odd length hex string"},
// Single completePart with valid MD5 hash string.
{[]completePart{{ETag: "cf1f738a5924e645913c984e0fe3d708"}}, "10dc1617fbcf0bd0858048cb96e6bd77-1", ""},
// Multiple completePart with valid MD5 hash string.
{[]completePart{{ETag: "cf1f738a5924e645913c984e0fe3d708"}, {ETag: "9ccbc9a80eee7fb6fdd22441db2aedbd"}}, "0239a86b5266bb624f0ac60ba2aed6c8-2", ""},
}
for i, test := range testCases {
result, err := getCompleteMultipartMD5(test.parts...)
if result != test.expectedResult {
t.Fatalf("test %d failed: expected: result=%v, got=%v", i+1, test.expectedResult, result)
}
errString := ""
if err != nil {
errString = err.Error()
}
if errString != test.expectedErr {
t.Fatalf("test %d failed: expected: err=%v, got=%v", i+1, test.expectedErr, err)
}
}
}

View File

@ -649,7 +649,7 @@ func (xl xlObjects) CompleteMultipartUpload(bucket string, object string, upload
return "", traceError(InvalidUploadID{UploadID: uploadID})
}
// Calculate s3 compatible md5sum for complete multipart.
s3MD5, err := completeMultipartMD5(parts...)
s3MD5, err := getCompleteMultipartMD5(parts...)
if err != nil {
return "", err
}