s3/test: fix minio bucket creation in tests (#1617)

This commit is contained in:
Julio Lopez
2021-12-22 20:40:56 -08:00
committed by GitHub
parent 294f053a3e
commit 01d7d109cb

View File

@@ -257,7 +257,7 @@ func TestS3StorageMinio(t *testing.T) {
DoNotUseTLS: true,
}
getOrCreateBucket(t, options)
createBucket(t, options)
testStorage(t, options, true, blob.PutOptions{})
}
@@ -292,7 +292,7 @@ func TestS3StorageMinioSelfSignedCert(t *testing.T) {
DoNotVerifyTLS: true,
}
getOrCreateBucket(t, options)
createBucket(t, options)
testStorage(t, options, true, blob.PutOptions{})
}
@@ -333,7 +333,7 @@ func TestS3StorageMinioSTS(t *testing.T) {
kopiaAccessKeyID, kopiaSecretKey, kopiaSessionToken := createMinioSessionToken(t, minioEndpoint, minioRootAccessKeyID, minioRootSecretAccessKey, minioBucketName)
getOrCreateBucket(t, &Options{
createBucket(t, &Options{
Endpoint: minioEndpoint,
AccessKeyID: minioRootAccessKeyID,
SecretAccessKey: minioRootSecretAccessKey,
@@ -518,6 +518,14 @@ func getOrCreateBucket(tb testing.TB, opt *Options) {
getOrMakeBucket(tb, minioClient, opt, false)
}
func createBucket(tb testing.TB, opt *Options) {
tb.Helper()
minioClient := createClient(tb, opt)
makeBucket(tb, minioClient, opt, false)
}
func getOrMakeBucket(tb testing.TB, cli *minio.Client, opt *Options, objectLocking bool) {
tb.Helper()
@@ -532,6 +540,14 @@ func getOrMakeBucket(tb testing.TB, cli *minio.Client, opt *Options, objectLocki
return
}
makeBucket(tb, cli, opt, objectLocking)
}
func makeBucket(tb testing.TB, cli *minio.Client, opt *Options, objectLocking bool) {
tb.Helper()
ctx := testlogging.Context(tb)
if err := cli.MakeBucket(ctx, opt.BucketName, minio.MakeBucketOptions{
Region: opt.Region,
ObjectLocking: objectLocking,