Tests replacing an object with CopyObject and a new Checksum type
()
| 9346 | |
| 9347 | // Tests replacing an object with CopyObject and a new Checksum type |
| 9348 | func testReplaceObjectWithChecksums() { |
| 9349 | startTime := time.Now() |
| 9350 | testName := getFuncName() |
| 9351 | function := "CopyObjectWithChecksums(destination, source)" |
| 9352 | args := map[string]interface{}{} |
| 9353 | |
| 9354 | c, err := NewClient(ClientConfig{CredsV2: true}) |
| 9355 | if err != nil { |
| 9356 | logError(testName, function, args, startTime, "", "MinIO v2 client object creation failed", err) |
| 9357 | return |
| 9358 | } |
| 9359 | |
| 9360 | // Generate a new random bucket name. |
| 9361 | bucketName := randString(60, rand.NewSource(time.Now().UnixNano()), "minio-go-test-") |
| 9362 | |
| 9363 | // Make a new bucket in 'us-east-1' (source bucket). |
| 9364 | err = c.MakeBucket(context.Background(), bucketName, minio.MakeBucketOptions{Region: "us-east-1"}) |
| 9365 | if err != nil { |
| 9366 | logError(testName, function, args, startTime, "", "MakeBucket failed", err) |
| 9367 | return |
| 9368 | } |
| 9369 | defer cleanupBucket(bucketName, c) |
| 9370 | |
| 9371 | tests := []struct { |
| 9372 | csType minio.ChecksumType |
| 9373 | cs wantChecksums |
| 9374 | }{ |
| 9375 | {csType: minio.ChecksumCRC64NVME, cs: wantChecksums{minio.ChecksumCRC64NVME: "iRtfQH3xflQ="}}, |
| 9376 | {csType: minio.ChecksumCRC32C, cs: wantChecksums{minio.ChecksumCRC32C: "aHnJMw=="}}, |
| 9377 | {csType: minio.ChecksumCRC32, cs: wantChecksums{minio.ChecksumCRC32: "tIZ8hA=="}}, |
| 9378 | {csType: minio.ChecksumSHA1, cs: wantChecksums{minio.ChecksumSHA1: "6YIIbcWH1iLaCFqs5vwq5Rwvm+o="}}, |
| 9379 | {csType: minio.ChecksumSHA256, cs: wantChecksums{minio.ChecksumSHA256: "GKeJTopbMGPs3h4fAw4oe0R2QnnmFVJeIWkqCkp28Yo="}}, |
| 9380 | // In S3, all copied objects without checksums and specified destination checksum algorithms |
| 9381 | // automatically gain a CRC-64NVME checksum algorithm. Use ChecksumNone for this case. |
| 9382 | {csType: minio.ChecksumNone, cs: wantChecksums{minio.ChecksumCRC64NVME: "iRtfQH3xflQ="}}, |
| 9383 | } |
| 9384 | |
| 9385 | for _, test := range tests { |
| 9386 | args := map[string]interface{}{} |
| 9387 | args["section"] = "setup" |
| 9388 | args["destOpts"] = "" |
| 9389 | args["checksum"] = test.csType.String() |
| 9390 | |
| 9391 | bufSize := dataFileMap["datafile-33-kB"] |
| 9392 | reader := getDataReader("datafile-33-kB") |
| 9393 | defer reader.Close() |
| 9394 | |
| 9395 | // PutObject to upload the object to the bucket |
| 9396 | objectName := randString(60, rand.NewSource(time.Now().UnixNano()), "") |
| 9397 | _, err = c.PutObject(context.Background(), bucketName, objectName, reader, int64(bufSize), minio.PutObjectOptions{ContentType: "binary/octet-stream"}) |
| 9398 | if err != nil { |
| 9399 | logError(testName, function, args, startTime, "", "PutObject failed", err) |
| 9400 | return |
| 9401 | } |
| 9402 | // GetObject to obtain the eTag |
| 9403 | r, err := c.GetObject(context.Background(), bucketName, objectName, minio.GetObjectOptions{}) |
| 9404 | if err != nil { |
| 9405 | logError(testName, function, args, startTime, "", "GetObject failed", err) |
no test coverage detected