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

Function testFPutObject

functional_tests.go:4645–4799  ·  view source on GitHub ↗

Tests FPutObject with null contentType (default = application/octet-stream)

()

Source from the content-addressed store, hash-verified

4643
4644// Tests FPutObject with null contentType (default = application/octet-stream)
4645func testFPutObject() {
4646 // initialize logging params
4647 startTime := time.Now()
4648 testName := getFuncName()
4649 function := "FPutObject(bucketName, objectName, fileName, opts)"
4650
4651 args := map[string]interface{}{
4652 "bucketName": "",
4653 "objectName": "",
4654 "fileName": "",
4655 "opts": "",
4656 }
4657
4658 c, err := NewClient(ClientConfig{})
4659 if err != nil {
4660 logError(testName, function, args, startTime, "", "MinIO client object creation failed", err)
4661 return
4662 }
4663
4664 // Generate a new random bucket name.
4665 bucketName := randString(60, rand.NewSource(time.Now().UnixNano()), "minio-go-test-")
4666 location := "us-east-1"
4667
4668 // Make a new bucket.
4669 args["bucketName"] = bucketName
4670 args["location"] = location
4671 function = "MakeBucket(bucketName, location)"
4672 err = c.MakeBucket(context.Background(), bucketName, minio.MakeBucketOptions{Region: location})
4673 if err != nil {
4674 logError(testName, function, args, startTime, "", "MakeBucket failed", err)
4675 return
4676 }
4677
4678 defer cleanupBucket(bucketName, c)
4679
4680 // Upload 3 parts worth of data to use all 3 of multiparts 'workers' and have an extra part.
4681 // Use different data in part for multipart tests to check parts are uploaded in correct order.
4682 fName := getMintDataDirFilePath("datafile-129-MB")
4683 if fName == "" {
4684 // Make a temp file with minPartSize bytes of data.
4685 file, err := os.CreateTemp(os.TempDir(), "FPutObjectTest")
4686 if err != nil {
4687 logError(testName, function, args, startTime, "", "TempFile creation failed", err)
4688 return
4689 }
4690
4691 // Upload 3 parts to utilize all 3 'workers' in multipart and still have a part to upload.
4692 if _, err = io.Copy(file, getDataReader("datafile-129-MB")); err != nil {
4693 logError(testName, function, args, startTime, "", "File copy failed", err)
4694 return
4695 }
4696 // Close the file pro-actively for windows.
4697 if err = file.Close(); err != nil {
4698 logError(testName, function, args, startTime, "", "File close failed", err)
4699 return
4700 }
4701 defer os.Remove(file.Name())
4702 fName = file.Name()

Callers 1

mainFunction · 0.85

Calls 13

MakeBucketMethod · 0.95
FPutObjectMethod · 0.95
StatObjectMethod · 0.95
getFuncNameFunction · 0.85
NewClientFunction · 0.85
logErrorFunction · 0.85
cleanupBucketFunction · 0.85
getMintDataDirFilePathFunction · 0.85
getDataReaderFunction · 0.85
logSuccessFunction · 0.85
randStringFunction · 0.70
CloseMethod · 0.45

Tested by

no test coverage detected