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

Function testPutMultipartObjectWithChecksums

functional_tests.go:2504–2846  ·  view source on GitHub ↗

Test PutObject with custom checksums.

()

Source from the content-addressed store, hash-verified

2502
2503// Test PutObject with custom checksums.
2504func testPutMultipartObjectWithChecksums() {
2505 // initialize logging params
2506 startTime := time.Now()
2507 testName := getFuncName()
2508 function := "PutObject(bucketName, objectName, reader,size, opts)"
2509 args := map[string]interface{}{
2510 "bucketName": "",
2511 "objectName": "",
2512 "opts": "minio.PutObjectOptions{UserMetadata: metadata, Trailing: true}",
2513 }
2514
2515 if !isFullMode() {
2516 logIgnored(testName, function, args, startTime, "Skipping functional tests for short/quick runs")
2517 return
2518 }
2519
2520 c, err := NewClient(ClientConfig{TrailingHeaders: true})
2521 if err != nil {
2522 logError(testName, function, args, startTime, "", "MinIO client object creation failed", err)
2523 return
2524 }
2525
2526 // Generate a new random bucket name.
2527 bucketName := randString(60, rand.NewSource(time.Now().UnixNano()), "minio-go-test-")
2528 args["bucketName"] = bucketName
2529
2530 // Make a new bucket.
2531 err = c.MakeBucket(context.Background(), bucketName, minio.MakeBucketOptions{Region: "us-east-1"})
2532 if err != nil {
2533 logError(testName, function, args, startTime, "", "Make bucket failed", err)
2534 return
2535 }
2536
2537 hashMultiPart := func(b []byte, partSize int, cs minio.ChecksumType) string {
2538 r := bytes.NewReader(b)
2539 hasher := cs.Hasher()
2540 if cs.FullObjectRequested() {
2541 partSize = len(b)
2542 }
2543 tmp := make([]byte, partSize)
2544 parts := 0
2545 var all []byte
2546 for {
2547 n, err := io.ReadFull(r, tmp)
2548 if err != nil && err != io.ErrUnexpectedEOF && err != io.EOF {
2549 logError(testName, function, args, startTime, "", "Calc crc failed", err)
2550 }
2551 if n == 0 {
2552 break
2553 }
2554 parts++
2555 hasher.Reset()
2556 hasher.Write(tmp[:n])
2557 all = append(all, hasher.Sum(nil)...)
2558 if err != nil {
2559 break
2560 }
2561 }

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