summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/minio/minio-go/v7/functional_tests.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/minio/minio-go/v7/functional_tests.go')
-rw-r--r--vendor/github.com/minio/minio-go/v7/functional_tests.go152
1 files changed, 146 insertions, 6 deletions
diff --git a/vendor/github.com/minio/minio-go/v7/functional_tests.go b/vendor/github.com/minio/minio-go/v7/functional_tests.go
index b8950dd2..413b63e5 100644
--- a/vendor/github.com/minio/minio-go/v7/functional_tests.go
+++ b/vendor/github.com/minio/minio-go/v7/functional_tests.go
@@ -1,3 +1,4 @@
+//go:build mint
// +build mint
/*
@@ -2627,6 +2628,138 @@ func testRemoveMultipleObjects() {
successLogger(testName, function, args, startTime).Info()
}
+// Test removing multiple objects and check for results
+func testRemoveMultipleObjectsWithResult() {
+ // initialize logging params
+ startTime := time.Now()
+ testName := getFuncName()
+ function := "RemoveObjects(bucketName, objectsCh)"
+ args := map[string]interface{}{
+ "bucketName": "",
+ }
+
+ // Seed random based on current time.
+ rand.Seed(time.Now().Unix())
+
+ // Instantiate new minio client object.
+ c, err := minio.New(os.Getenv(serverEndpoint),
+ &minio.Options{
+ Creds: credentials.NewStaticV4(os.Getenv(accessKey), os.Getenv(secretKey), ""),
+ Secure: mustParseBool(os.Getenv(enableHTTPS)),
+ })
+ if err != nil {
+ logError(testName, function, args, startTime, "", "MinIO client object creation failed", err)
+ return
+ }
+
+ // Set user agent.
+ c.SetAppInfo("MinIO-go-FunctionalTest", "0.1.0")
+
+ // Enable tracing, write to stdout.
+ // c.TraceOn(os.Stderr)
+
+ // Generate a new random bucket name.
+ bucketName := randString(60, rand.NewSource(time.Now().UnixNano()), "minio-go-test-")
+ args["bucketName"] = bucketName
+
+ // Make a new bucket.
+ err = c.MakeBucket(context.Background(), bucketName, minio.MakeBucketOptions{Region: "us-east-1", ObjectLocking: true})
+ if err != nil {
+ logError(testName, function, args, startTime, "", "MakeBucket failed", err)
+ return
+ }
+
+ defer cleanupVersionedBucket(bucketName, c)
+
+ r := bytes.NewReader(bytes.Repeat([]byte("a"), 8))
+
+ nrObjects := 10
+ nrLockedObjects := 5
+
+ objectsCh := make(chan minio.ObjectInfo)
+
+ go func() {
+ defer close(objectsCh)
+ // Upload objects and send them to objectsCh
+ for i := 0; i < nrObjects; i++ {
+ objectName := "sample" + strconv.Itoa(i) + ".txt"
+ info, err := c.PutObject(context.Background(), bucketName, objectName, r, 8,
+ minio.PutObjectOptions{ContentType: "application/octet-stream"})
+ if err != nil {
+ logError(testName, function, args, startTime, "", "PutObject failed", err)
+ return
+ }
+ if i < nrLockedObjects {
+ // t := time.Date(2130, time.April, 25, 14, 0, 0, 0, time.UTC)
+ t := time.Now().Add(5 * time.Minute)
+ m := minio.RetentionMode(minio.Governance)
+ opts := minio.PutObjectRetentionOptions{
+ GovernanceBypass: false,
+ RetainUntilDate: &t,
+ Mode: &m,
+ VersionID: info.VersionID,
+ }
+ err = c.PutObjectRetention(context.Background(), bucketName, objectName, opts)
+ if err != nil {
+ logError(testName, function, args, startTime, "", "Error setting retention", err)
+ return
+ }
+ }
+
+ objectsCh <- minio.ObjectInfo{
+ Key: info.Key,
+ VersionID: info.VersionID,
+ }
+ }
+ }()
+
+ // Call RemoveObjects API
+ resultCh := c.RemoveObjectsWithResult(context.Background(), bucketName, objectsCh, minio.RemoveObjectsOptions{})
+
+ var foundNil, foundErr int
+
+ for {
+ // Check if errorCh doesn't receive any error
+ select {
+ case deleteRes, ok := <-resultCh:
+ if !ok {
+ goto out
+ }
+ if deleteRes.ObjectName == "" {
+ logError(testName, function, args, startTime, "", "Unexpected object name", nil)
+ return
+ }
+ if deleteRes.ObjectVersionID == "" {
+ logError(testName, function, args, startTime, "", "Unexpected object version ID", nil)
+ return
+ }
+
+ if deleteRes.Err == nil {
+ foundNil++
+ } else {
+ foundErr++
+ }
+ }
+ }
+out:
+ if foundNil+foundErr != nrObjects {
+ logError(testName, function, args, startTime, "", "Unexpected number of results", nil)
+ return
+ }
+
+ if foundNil != nrObjects-nrLockedObjects {
+ logError(testName, function, args, startTime, "", "Unexpected number of nil errors", nil)
+ return
+ }
+
+ if foundErr != nrLockedObjects {
+ logError(testName, function, args, startTime, "", "Unexpected number of errors", nil)
+ return
+ }
+
+ successLogger(testName, function, args, startTime).Info()
+}
+
// Tests FPutObject of a big file to trigger multipart
func testFPutObjectMultipart() {
// initialize logging params
@@ -11297,12 +11430,6 @@ func testGetObjectACLContext() {
// Seed random based on current time.
rand.Seed(time.Now().Unix())
- // skipping region functional tests for non s3 runs
- if os.Getenv(serverEndpoint) != "s3.amazonaws.com" {
- ignoredLog(testName, function, args, startTime, "Skipped region functional tests for non s3 runs").Info()
- return
- }
-
// Instantiate new minio client object.
c, err := minio.New(os.Getenv(serverEndpoint),
&minio.Options{
@@ -11379,6 +11506,17 @@ func testGetObjectACLContext() {
return
}
+ // Do a very limited testing if this is not AWS S3
+ if os.Getenv(serverEndpoint) != "s3.amazonaws.com" {
+ if s[0] != "private" {
+ logError(testName, function, args, startTime, "", "GetObjectACL fail \"X-Amz-Acl\" expected \"private\" but got"+fmt.Sprintf("%q", s[0]), nil)
+ return
+ }
+
+ successLogger(testName, function, args, startTime).Info()
+ return
+ }
+
if s[0] != "public-read-write" {
logError(testName, function, args, startTime, "", "GetObjectACL fail \"X-Amz-Acl\" expected \"public-read-write\" but got"+fmt.Sprintf("%q", s[0]), nil)
return
@@ -11978,6 +12116,7 @@ func main() {
// Default to KMS tests.
kms = true
}
+
// execute tests
if isFullMode() {
testMakeBucketErrorV2()
@@ -12009,6 +12148,7 @@ func main() {
testGetObjectClosedTwice()
testGetObjectS3Zip()
testRemoveMultipleObjects()
+ testRemoveMultipleObjectsWithResult()
testFPutObjectMultipart()
testFPutObject()
testGetObjectReadSeekFunctional()