Skip to content

Commit 9ecbe63

Browse files
committed
tests: Fix Bucket soft-delete tests.
The soft-deleted buckets were being tracker by the fixture. The fixture tracks buckets for deletion which is done on a best effort basis, so that's not the problem. But, tracked buckets are also use as the expected result for ListAllBuckets tests, so these soft-deleted buckets were being expected but they were not showing up in actual lists.
1 parent 449b11f commit 9ecbe63

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/GetBucketTest.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ public GetBucketTest(StorageFixture fixture)
3232
public async Task SoftDeleted()
3333
{
3434
var bucketName = _fixture.GenerateBucketName();
35-
var softDeleteBucket = _fixture.CreateBucket(bucketName, multiVersion: false, softDelete: true);
35+
var softDeleteBucket = _fixture.CreateBucket(bucketName, multiVersion: false, softDelete: true, registerForDeletion: false);
36+
3637
await _fixture.Client.DeleteBucketAsync(softDeleteBucket.Name, new DeleteBucketOptions { DeleteObjects = true });
3738

3839
var softDeleted = await _fixture.Client.GetBucketAsync(softDeleteBucket.Name, new GetBucketOptions { SoftDeleted = true, Generation = softDeleteBucket.Generation });

apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/ListBucketsTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public void PartialResponses()
7979
public async Task SoftDeletedOnly()
8080
{
8181
var bucketName = _fixture.GenerateBucketName();
82-
var softDeleteBucket = _fixture.CreateBucket(bucketName, multiVersion: false, softDelete: true);
82+
var softDeleteBucket = _fixture.CreateBucket(bucketName, multiVersion: false, softDelete: true, registerForDeletion: false);
8383

8484
await _fixture.Client.DeleteBucketAsync(softDeleteBucket.Name, new DeleteBucketOptions { DeleteObjects = true });
8585

apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1.IntegrationTests/StorageFixture.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ void CreateObject()
249249

250250
}
251251

252-
internal Bucket CreateBucket(string name, bool multiVersion, bool softDelete = false)
252+
internal Bucket CreateBucket(string name, bool multiVersion, bool softDelete = false, bool registerForDeletion = true)
253253
{
254254
var bucket = Client.CreateBucket(ProjectId,
255255
new Bucket
@@ -260,7 +260,10 @@ internal Bucket CreateBucket(string name, bool multiVersion, bool softDelete = f
260260
SoftDeletePolicy = softDelete ? new Bucket.SoftDeletePolicyData { RetentionDurationSeconds = (int) TimeSpan.FromDays(7).TotalSeconds } : null,
261261
});
262262
SleepAfterBucketCreateDelete();
263-
RegisterBucketToDelete(name);
263+
if (registerForDeletion)
264+
{
265+
RegisterBucketToDelete(name);
266+
}
264267
return bucket;
265268
}
266269

0 commit comments

Comments
 (0)