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

Function testPutObjectWithAutomaticChecksums

functional_tests.go:3163–3303  ·  view source on GitHub ↗

Test PutObject with custom checksums.

()

Source from the content-addressed store, hash-verified

3161
3162// Test PutObject with custom checksums.
3163func testPutObjectWithAutomaticChecksums() {
3164 // initialize logging params
3165 startTime := time.Now()
3166 testName := getFuncName()
3167 function := "PutObject(bucketName, objectName, reader,size, opts)"
3168 args := map[string]interface{}{
3169 "bucketName": "",
3170 "objectName": "",
3171 "opts": "minio.PutObjectOptions{UserMetadata: metadata, Progress: progress}",
3172 }
3173
3174 if !isFullMode() {
3175 logIgnored(testName, function, args, startTime, "Skipping functional tests for short/quick runs")
3176 return
3177 }
3178
3179 c, err := NewClient(ClientConfig{TrailingHeaders: true})
3180 if err != nil {
3181 logError(testName, function, args, startTime, "", "MinIO client object creation failed", err)
3182 return
3183 }
3184
3185 // Generate a new random bucket name.
3186 bucketName := randString(60, rand.NewSource(time.Now().UnixNano()), "minio-go-test-")
3187 args["bucketName"] = bucketName
3188
3189 // Make a new bucket.
3190 err = c.MakeBucket(context.Background(), bucketName, minio.MakeBucketOptions{Region: "us-east-1"})
3191 if err != nil {
3192 logError(testName, function, args, startTime, "", "Make bucket failed", err)
3193 return
3194 }
3195
3196 defer cleanupBucket(bucketName, c)
3197 tests := []struct {
3198 header string
3199 hasher hash.Hash
3200
3201 // Checksum values
3202 ChecksumCRC32 string
3203 ChecksumCRC32C string
3204 ChecksumSHA1 string
3205 ChecksumSHA256 string
3206 }{
3207 // Built-in will only add crc32c, when no MD5 nor SHA256.
3208 {header: "x-amz-checksum-crc32c", hasher: crc32.New(crc32.MakeTable(crc32.Castagnoli))},
3209 }
3210
3211 // defer c.TraceOff()
3212
3213 for i, test := range tests {
3214 bufSize := dataFileMap["datafile-10-kB"]
3215
3216 // Save the data
3217 objectName := randString(60, rand.NewSource(time.Now().UnixNano()), "")
3218 args["objectName"] = objectName
3219
3220 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