MCPcopy
hub / github.com/minio/minio-go / testPutObjectWithMetadata

Function testPutObjectWithMetadata

functional_tests.go:3834–3927  ·  view source on GitHub ↗

Test PutObject using a large data to trigger multipart readat

()

Source from the content-addressed store, hash-verified

3832
3833// Test PutObject using a large data to trigger multipart readat
3834func testPutObjectWithMetadata() {
3835 // initialize logging params
3836 startTime := time.Now()
3837 testName := getFuncName()
3838 function := "PutObject(bucketName, objectName, reader,size, opts)"
3839 args := map[string]interface{}{
3840 "bucketName": "",
3841 "objectName": "",
3842 "opts": "minio.PutObjectOptions{UserMetadata: metadata, Progress: progress}",
3843 }
3844
3845 if !isFullMode() {
3846 logIgnored(testName, function, args, startTime, "Skipping functional tests for short/quick runs")
3847 return
3848 }
3849
3850 c, err := NewClient(ClientConfig{})
3851 if err != nil {
3852 logError(testName, function, args, startTime, "", "MinIO client object creation failed", err)
3853 return
3854 }
3855
3856 // Generate a new random bucket name.
3857 bucketName := randString(60, rand.NewSource(time.Now().UnixNano()), "minio-go-test-")
3858 args["bucketName"] = bucketName
3859
3860 // Make a new bucket.
3861 err = c.MakeBucket(context.Background(), bucketName, minio.MakeBucketOptions{Region: "us-east-1"})
3862 if err != nil {
3863 logError(testName, function, args, startTime, "", "Make bucket failed", err)
3864 return
3865 }
3866
3867 defer cleanupBucket(bucketName, c)
3868
3869 bufSize := dataFileMap["datafile-129-MB"]
3870 reader := getDataReader("datafile-129-MB")
3871 defer reader.Close()
3872
3873 // Save the data
3874 objectName := randString(60, rand.NewSource(time.Now().UnixNano()), "")
3875 args["objectName"] = objectName
3876
3877 // Object custom metadata
3878 customContentType := "custom/contenttype"
3879
3880 args["metadata"] = map[string][]string{
3881 "Content-Type": {customContentType},
3882 "X-Amz-Meta-CustomKey": {"extra spaces in value"},
3883 }
3884
3885 _, err = c.PutObject(context.Background(), bucketName, objectName, reader, int64(bufSize), minio.PutObjectOptions{
3886 ContentType: customContentType,
3887 })
3888 if err != nil {
3889 logError(testName, function, args, startTime, "", "PutObject failed", err)
3890 return
3891 }

Callers 1

mainFunction · 0.85

Calls 15

MakeBucketMethod · 0.95
PutObjectMethod · 0.95
GetObjectMethod · 0.95
getFuncNameFunction · 0.85
isFullModeFunction · 0.85
logIgnoredFunction · 0.85
NewClientFunction · 0.85
logErrorFunction · 0.85
cleanupBucketFunction · 0.85
getDataReaderFunction · 0.85
crcMatchesNameFunction · 0.85
logSuccessFunction · 0.85

Tested by

no test coverage detected