Skip to content

Commit

Permalink
tests: Fix hasExtendedHeader tests with env variable.
Browse files Browse the repository at this point in the history
  • Loading branch information
harshavardhana committed Aug 15, 2016
1 parent bb8a425 commit 3d1bb8f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
15 changes: 9 additions & 6 deletions fs-v1-metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@

package main

import "testing"
import (
"os"
"testing"
)

// Tests scenarios which can occur for hasExtendedHeader function.
func TestHasExtendedHeader(t *testing.T) {
Expand All @@ -30,26 +33,26 @@ func TestHasExtendedHeader(t *testing.T) {
metadata: map[string]string{
"X-Amz-Meta-1": "value",
},
has: true,
has: true || os.Getenv("MINIO_ENABLE_FSMETA") == "1",
},
// Verifies if X-Minio-Meta is present.
{
metadata: map[string]string{
"X-Minio-Meta-1": "value",
},
has: true,
has: true || os.Getenv("MINIO_ENABLE_FSMETA") == "1",
},
// Verifies if extended header is not present.
{
metadata: map[string]string{
"md5Sum": "value",
},
has: false,
has: false || os.Getenv("MINIO_ENABLE_FSMETA") == "1",
},
// Verifieis if extended header is not present, but with an empty input.
// Verifies if extended header is not present, but with an empty input.
{
metadata: nil,
has: false,
has: false || os.Getenv("MINIO_ENABLE_FSMETA") == "1",
},
}

Expand Down
3 changes: 3 additions & 0 deletions fs-v1-multipart.go
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,9 @@ func (fs fsObjects) CompleteMultipartUpload(bucket string, object string, upload

// Save additional metadata only if extended headers such as "X-Amz-Meta-" are set.
if hasExtendedHeader(fsMeta.Meta) {
if len(fsMeta.Meta) == 0 {
fsMeta.Meta = make(map[string]string)
}
fsMeta.Meta["md5Sum"] = s3MD5

// Write the metadata to a temp file and rename it to the actual location.
Expand Down

0 comments on commit 3d1bb8f

Please sign in to comment.