Skip to content

Commit

Permalink
Don't fail a test if bucket already exists
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeyRyabinin committed Dec 13, 2023
1 parent ce68fbf commit 3a53010
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
9 changes: 8 additions & 1 deletion tests/aws-cpp-sdk-s3-crt-integration-tests/S3ExpressTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ namespace {
public:
CreateBucketOutcome CreateBucket(const Aws::String &bucketName = randomString() + S3_EXPRESS_SUFFIX) {
bucketsToCleanup.push_back(bucketName);
return client->CreateBucket(CreateBucketRequest()
CreateBucketOutcome outcome = client->CreateBucket(CreateBucketRequest()
.WithBucket(bucketName)
.WithCreateBucketConfiguration(CreateBucketConfiguration()
.WithLocation(LocationInfo()
Expand All @@ -64,6 +64,13 @@ namespace {
.WithBucket(BucketInfo()
.WithType(BucketType::Directory)
.WithDataRedundancy(DataRedundancy::SingleAvailabilityZone))));

if (!outcome.IsSuccess() && outcome.GetError().GetResponseCode() == Aws::Http::HttpResponseCode::CONFLICT &&
outcome.GetError().GetExceptionName() == "BucketAlreadyOwnedByYou") {
return CreateBucketOutcome(CreateBucketResult());
}

return outcome;
}

DeleteBucketOutcome DeleteBucket(const Aws::String &bucketName) {
Expand Down
9 changes: 8 additions & 1 deletion tests/aws-cpp-sdk-s3-integration-tests/S3ExpressTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ namespace {
public:
CreateBucketOutcome CreateBucket(const Aws::String &bucketName = randomString() + S3_EXPRESS_SUFFIX) {
bucketsToCleanup.push_back(bucketName);
return client->CreateBucket(CreateBucketRequest()
CreateBucketOutcome outcome = client->CreateBucket(CreateBucketRequest()
.WithBucket(bucketName)
.WithCreateBucketConfiguration(CreateBucketConfiguration()
.WithLocation(LocationInfo()
Expand All @@ -64,6 +64,13 @@ namespace {
.WithBucket(BucketInfo()
.WithType(BucketType::Directory)
.WithDataRedundancy(DataRedundancy::SingleAvailabilityZone))));

if (!outcome.IsSuccess() && outcome.GetError().GetResponseCode() == Aws::Http::HttpResponseCode::CONFLICT &&
outcome.GetError().GetExceptionName() == "BucketAlreadyOwnedByYou") {
return CreateBucketOutcome(CreateBucketResult());
}

return outcome;
}

DeleteBucketOutcome DeleteBucket(const Aws::String &bucketName) {
Expand Down

0 comments on commit 3a53010

Please sign in to comment.