Skip to content

feat(.NET): add deleteFolderRecursive sample#3337

Draft
nidhiii-27 wants to merge 2 commits into
mainfrom
add-delete-folder-recursive-sample
Draft

feat(.NET): add deleteFolderRecursive sample#3337
nidhiii-27 wants to merge 2 commits into
mainfrom
add-delete-folder-recursive-sample

Conversation

@nidhiii-27

Copy link
Copy Markdown

This adds a sample demonstrating how to recursively delete a folder in a hierarchical namespace bucket.

Fixes: b/521168740

This adds a sample demonstrating how to recursively delete a folder in a hierarchical namespace bucket.

Fixes: b/521168740

[Generated-by: AI]
@nidhiii-27 nidhiii-27 requested review from a team as code owners June 11, 2026 10:55
@snippet-bot

snippet-bot Bot commented Jun 11, 2026

Copy link
Copy Markdown

Here is the summary of changes.

You are about to add 1 region tag.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@product-auto-label product-auto-label Bot added the samples Issues that are directly related to samples. label Jun 11, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new sample and test for recursively deleting folders using the StorageControlClient. The review feedback suggests improving test reliability by using a dynamically generated folder name to prevent test interference, and asserting on the folder's resource name instead of the entire Folder object to avoid failures from volatile fields.

Comment on lines +32 to +36
StorageControlCreateFolderSample createSample = new StorageControlCreateFolderSample();
var folder = createSample.StorageControlCreateFolder(_fixture.BucketNameHns, "deleteRecursiveTestFolder");

StorageControlDeleteFolderRecursiveSample deleteSample = new StorageControlDeleteFolderRecursiveSample();
deleteSample.StorageControlDeleteFolderRecursive(_fixture.BucketNameHns, "deleteRecursiveTestFolder");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using a hardcoded folder name like "deleteRecursiveTestFolder" can lead to test interference or flakiness if multiple tests run concurrently or if a previous test run failed to clean up. It is safer to use a dynamically generated folder name using _fixture.GenerateName().

        string folderName = _fixture.GenerateName();
        StorageControlCreateFolderSample createSample = new StorageControlCreateFolderSample();
        var folder = createSample.StorageControlCreateFolder(_fixture.BucketNameHns, folderName);

        StorageControlDeleteFolderRecursiveSample deleteSample = new StorageControlDeleteFolderRecursiveSample();
        deleteSample.StorageControlDeleteFolderRecursive(_fixture.BucketNameHns, folderName);

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

StorageControlListFoldersSample listFoldersSample = new StorageControlListFoldersSample();
var folders = listFoldersSample.StorageControlListFolders(_fixture.BucketNameHns);

Assert.DoesNotContain(folder, folders);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Asserting on the full Folder object might fail if there are volatile fields (such as update times or metadata) that differ between creation and listing. It is more robust to assert that no folder with the same resource name exists in the list using a predicate.

        Assert.DoesNotContain(folders, f => f.Name == folder.Name);

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@nidhiii-27 nidhiii-27 marked this pull request as draft June 11, 2026 11:00
@nidhiii-27 nidhiii-27 added ai-generated Generated by AI storage-sample-architect Generated by storage-sample-architect skill labels Jun 11, 2026
- Update Google.Cloud.Storage.Control.V2 to 1.8.0 to resolve DeleteFolderRecursive method
- Use fixture.GenerateName() instead of hardcoded folder name in tests
- Assert with predicate instead of on the full Folder object to prevent flaky tests

[Generated-by: AI]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-generated Generated by AI samples Issues that are directly related to samples. storage-sample-architect Generated by storage-sample-architect skill

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant