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

Function testPutMultipartObjectWithChecksums

functional_tests.go:2608–2950  ·  view source on GitHub ↗

Test PutObject with custom checksums.

()

Source from the content-addressed store, hash-verified

2606
2607// Test PutObject with custom checksums.
2608func testPutMultipartObjectWithChecksums() {
2609 // initialize logging params
2610 startTime := time.Now()
2611 testName := getFuncName()
2612 function := "PutObject(bucketName, objectName, reader,size, opts)"
2613 args := map[string]interface{}{
2614 "bucketName": "",
2615 "objectName": "",
2616 "opts": "minio.PutObjectOptions{UserMetadata: metadata, Trailing: true}",
2617 }
2618
2619 if !isFullMode() {
2620 logIgnored(testName, function, args, startTime, "Skipping functional tests for short/quick runs")
2621 return
2622 }
2623
2624 c, err := NewClient(ClientConfig{TrailingHeaders: true})
2625 if err != nil {
2626 logError(testName, function, args, startTime, "", "MinIO client object creation failed", err)
2627 return
2628 }
2629
2630 // Generate a new random bucket name.
2631 bucketName := randString(60, rand.NewSource(time.Now().UnixNano()), "minio-go-test-")
2632 args["bucketName"] = bucketName
2633
2634 // Make a new bucket.
2635 err = c.MakeBucket(context.Background(), bucketName, minio.MakeBucketOptions{Region: "us-east-1"})
2636 if err != nil {
2637 logError(testName, function, args, startTime, "", "Make bucket failed", err)
2638 return
2639 }
2640
2641 hashMultiPart := func(b []byte, partSize int, cs minio.ChecksumType) string {
2642 r := bytes.NewReader(b)
2643 hasher := cs.Hasher()
2644 if cs.FullObjectRequested() {
2645 partSize = len(b)
2646 }
2647 tmp := make([]byte, partSize)
2648 parts := 0
2649 var all []byte
2650 for {
2651 n, err := io.ReadFull(r, tmp)
2652 if err != nil && err != io.ErrUnexpectedEOF && err != io.EOF {
2653 logError(testName, function, args, startTime, "", "Calc crc failed", err)
2654 }
2655 if n == 0 {
2656 break
2657 }
2658 parts++
2659 hasher.Reset()
2660 hasher.Write(tmp[:n])
2661 all = append(all, hasher.Sum(nil)...)
2662 if err != nil {
2663 break
2664 }
2665 }

Callers 1

mainFunction · 0.85

Calls 15

MakeBucketMethod · 0.95
PutObjectMethod · 0.95
StatObjectMethod · 0.95
CopyObjectMethod · 0.95
GetObjectAttributesMethod · 0.95
GetObjectMethod · 0.95
getFuncNameFunction · 0.85
isFullModeFunction · 0.85
logIgnoredFunction · 0.85
NewClientFunction · 0.85
logErrorFunction · 0.85
cleanupBucketFunction · 0.85

Tested by

no test coverage detected