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

Function testFPutObject

functional_tests.go:4749–4903  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

4747
4748// Tests FPutObject with null contentType (default = application/octet-stream)
4749func testFPutObject() {
4750 // initialize logging params
4751 startTime := time.Now()
4752 testName := getFuncName()
4753 function := "FPutObject(bucketName, objectName, fileName, opts)"
4754
4755 args := map[string]interface{}{
4756 "bucketName": "",
4757 "objectName": "",
4758 "fileName": "",
4759 "opts": "",
4760 }
4761
4762 c, err := NewClient(ClientConfig{})
4763 if err != nil {
4764 logError(testName, function, args, startTime, "", "MinIO client object creation failed", err)
4765 return
4766 }
4767
4768 // Generate a new random bucket name.
4769 bucketName := randString(60, rand.NewSource(time.Now().UnixNano()), "minio-go-test-")
4770 location := "us-east-1"
4771
4772 // Make a new bucket.
4773 args["bucketName"] = bucketName
4774 args["location"] = location
4775 function = "MakeBucket(bucketName, location)"
4776 err = c.MakeBucket(context.Background(), bucketName, minio.MakeBucketOptions{Region: location})
4777 if err != nil {
4778 logError(testName, function, args, startTime, "", "MakeBucket failed", err)
4779 return
4780 }
4781
4782 defer cleanupBucket(bucketName, c)
4783
4784 // Upload 3 parts worth of data to use all 3 of multiparts 'workers' and have an extra part.
4785 // Use different data in part for multipart tests to check parts are uploaded in correct order.
4786 fName := getMintDataDirFilePath("datafile-129-MB")
4787 if fName == "" {
4788 // Make a temp file with minPartSize bytes of data.
4789 file, err := os.CreateTemp(os.TempDir(), "FPutObjectTest")
4790 if err != nil {
4791 logError(testName, function, args, startTime, "", "TempFile creation failed", err)
4792 return
4793 }
4794
4795 // Upload 3 parts to utilize all 3 'workers' in multipart and still have a part to upload.
4796 if _, err = io.Copy(file, getDataReader("datafile-129-MB")); err != nil {
4797 logError(testName, function, args, startTime, "", "File copy failed", err)
4798 return
4799 }
4800 // Close the file pro-actively for windows.
4801 if err = file.Close(); err != nil {
4802 logError(testName, function, args, startTime, "", "File close failed", err)
4803 return
4804 }
4805 defer os.Remove(file.Name())
4806 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