github.com/weaviate/weaviate@v1.24.6/test/modules/backup-s3/helper_test.go (about)

     1  //                           _       _
     2  // __      _____  __ ___   ___  __ _| |_ ___
     3  // \ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \
     4  //  \ V  V /  __/ (_| |\ V /| | (_| | ||  __/
     5  //   \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___|
     6  //
     7  //  Copyright © 2016 - 2024 Weaviate B.V. All rights reserved.
     8  //
     9  //  CONTACT: hello@weaviate.io
    10  //
    11  
    12  package test
    13  
    14  import (
    15  	"context"
    16  	"testing"
    17  	"time"
    18  
    19  	"github.com/minio/minio-go/v7"
    20  	"github.com/minio/minio-go/v7/pkg/credentials"
    21  	"github.com/stretchr/testify/assert"
    22  	"github.com/stretchr/testify/require"
    23  )
    24  
    25  func createBucket(ctx context.Context, t *testing.T, endpoint, region, bucketName string) {
    26  	assert.EventuallyWithT(t, func(collect *assert.CollectT) {
    27  		client, err := minio.New(endpoint, &minio.Options{
    28  			Creds:  credentials.NewEnvAWS(),
    29  			Region: region,
    30  			Secure: false,
    31  		})
    32  		require.Nil(t, err)
    33  
    34  		err = client.MakeBucket(ctx, bucketName, minio.MakeBucketOptions{})
    35  		minioErr, ok := err.(minio.ErrorResponse)
    36  		if ok {
    37  			// the bucket persists from a previous test.
    38  			// if the bucket already exists, we can proceed
    39  			if minioErr.Code == "BucketAlreadyOwnedByYou" {
    40  				return
    41  			}
    42  		}
    43  		require.Nil(t, err)
    44  	}, 5*time.Second, 500*time.Millisecond)
    45  }