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

Function testPutObjectWithAutomaticChecksums

functional_tests.go:3059–3199  ·  view source on GitHub ↗

Test PutObject with custom checksums.

()

Source from the content-addressed store, hash-verified

3057
3058// Test PutObject with custom checksums.
3059func testPutObjectWithAutomaticChecksums() {
3060 // initialize logging params
3061 startTime := time.Now()
3062 testName := getFuncName()
3063 function := "PutObject(bucketName, objectName, reader,size, opts)"
3064 args := map[string]interface{}{
3065 "bucketName": "",
3066 "objectName": "",
3067 "opts": "minio.PutObjectOptions{UserMetadata: metadata, Progress: progress}",
3068 }
3069
3070 if !isFullMode() {
3071 logIgnored(testName, function, args, startTime, "Skipping functional tests for short/quick runs")
3072 return
3073 }
3074
3075 c, err := NewClient(ClientConfig{TrailingHeaders: true})
3076 if err != nil {
3077 logError(testName, function, args, startTime, "", "MinIO client object creation failed", err)
3078 return
3079 }
3080
3081 // Generate a new random bucket name.
3082 bucketName := randString(60, rand.NewSource(time.Now().UnixNano()), "minio-go-test-")
3083 args["bucketName"] = bucketName
3084
3085 // Make a new bucket.
3086 err = c.MakeBucket(context.Background(), bucketName, minio.MakeBucketOptions{Region: "us-east-1"})
3087 if err != nil {
3088 logError(testName, function, args, startTime, "", "Make bucket failed", err)
3089 return
3090 }
3091
3092 defer cleanupBucket(bucketName, c)
3093 tests := []struct {
3094 header string
3095 hasher hash.Hash
3096
3097 // Checksum values
3098 ChecksumCRC32 string
3099 ChecksumCRC32C string
3100 ChecksumSHA1 string
3101 ChecksumSHA256 string
3102 }{
3103 // Built-in will only add crc32c, when no MD5 nor SHA256.
3104 {header: "x-amz-checksum-crc32c", hasher: crc32.New(crc32.MakeTable(crc32.Castagnoli))},
3105 }
3106
3107 // defer c.TraceOff()
3108
3109 for i, test := range tests {
3110 bufSize := dataFileMap["datafile-10-kB"]
3111
3112 // Save the data
3113 objectName := randString(60, rand.NewSource(time.Now().UnixNano()), "")
3114 args["objectName"] = objectName
3115
3116 cmpChecksum := func(got, want string) {

Callers 1

mainFunction · 0.85

Calls 14

MakeBucketMethod · 0.95
PutObjectMethod · 0.95
getFuncNameFunction · 0.85
isFullModeFunction · 0.85
logIgnoredFunction · 0.85
NewClientFunction · 0.85
logErrorFunction · 0.85
cleanupBucketFunction · 0.85
getDataReaderFunction · 0.85
cmpChecksumFunction · 0.85
logSuccessFunction · 0.85
EncodeToStringMethod · 0.80

Tested by

no test coverage detected