Skip to content

test(storage): remove the buckets the suite creates - #1641

Merged
spydon merged 7 commits into
mainfrom
fix/storage-test-bucket-cleanup
Aug 5, 2026
Merged

test(storage): remove the buckets the suite creates#1641
spydon merged 7 commits into
mainfrom
fix/storage-test-bucket-cleanup

Conversation

@spydon

@spydon spydon commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Stacked on #1640, since it touches the same file.

The storage suite created buckets and never removed them, while List buckets asserted the total bucket count. A second run against the same stack therefore failed twice over: the listing saw the leftovers, and Create new public bucket hit a 409 because it uses a fixed name. Only CI got away with it, because every job starts a fresh stack.

  • Sweeps the buckets the suite creates before and after the run, so leftovers of an interrupted run cannot break the next one either. Only names the suite itself uses are removed, never the seeded buckets or those of another suite.
  • List buckets now asserts that the seeded buckets are listed instead of counting every bucket on the stack, so a suite running in parallel cannot fail it.

Verified by running the suite twice in a row against a stack that had 20 leftover buckets: both runs pass and leave exactly the four seeded buckets.

Summary by CodeRabbit

  • Tests
    • Improved storage client test reliability by documenting shared-state behavior and using a consistent temporary bucket namespace.
    • Added comprehensive cleanup for temporary buckets, including emptying buckets before removal and safely handling concurrent cleanup races.
    • Updated bucket listing coverage to verify expected seeded buckets are present without relying on a fixed total count.
    • Added safeguards to preserve seeded data and tolerate cleanup timing differences.

spydon added 5 commits August 5, 2026 09:17
The URL, ports and API keys of the local Supabase CLI stack were duplicated
across the test suites, the service role key alone in five places. Move them
into a testing library of supabase_common, annotated with @VisibleForTesting so
they cannot leak into runtime code.
The per package aliases only pointed at the shared constants, so the call
sites now reference those. Only the values that are actually derived from
them stay local.
The suite created buckets without removing them, so a second run against the
same stack failed on the bucket listing and on recreating a bucket with a fixed
name. The buckets it creates are now swept before and after the run, and the
listing assertion no longer depends on the total bucket count.
@spydon
spydon requested a review from a team as a code owner August 5, 2026 07:52
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: f7efa565-cfaf-4174-ba40-380ba6057558

📥 Commits

Reviewing files that changed from the base of the PR and between 020b09f and 34e6756.

📒 Files selected for processing (1)
  • packages/storage_client/test/client_test.dart

📝 Walkthrough

Walkthrough

The storage client tests use a shared temporary bucket namespace, clean up matching buckets before and after the suite, tolerate concurrent 404 errors, and verify that seeded buckets appear in listings.

Changes

Storage test isolation

Layer / File(s) Summary
Temporary bucket isolation and cleanup
packages/storage_client/test/client_test.dart
Temporary bucket names use the client-test- namespace. Suite hooks empty and delete matching buckets. Cleanup ignores concurrent 404 StorageException errors. Bucket-list validation checks for all seeded bucket names instead of requiring exactly four buckets.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: dshukertjr

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: removing buckets created by the storage test suite.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/storage-test-bucket-cleanup

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the storage This issue or pull request is related to storage label Aug 5, 2026
Base automatically changed from refactor/shared-local-stack-config to main August 5, 2026 08:02

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/storage_client/test/client_test.dart`:
- Around line 995-1013: Update the temporary bucket naming and cleanup around
_temporaryBucketPrefixes and _removeTemporaryBuckets to use a unique
suite-specific namespace for every bucket created by this test suite. Replace
broad startsWith matching with ownership-safe matching: require the namespace
for generated names and exact equality for fixed reserved names, while
preserving seeded buckets. Ensure all temporary bucket creation sites use the
same namespace.
- Around line 1015-1020: Update the cleanup catch around storage.emptyBucket and
storage.deleteBucket to ignore only the StorageException status indicating the
bucket is not found; rethrow every other StorageException so authorization,
server, and bucket-state failures remain visible.
- Around line 18-22: Wrap the overlong comment line in the test file so every
Dart source line stays within the 80-character limit, preserving the existing
wording and meaning; run dart format afterward.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 3f9b09e9-abd7-46a2-a70e-7ac307405c80

📥 Commits

Reviewing files that changed from the base of the PR and between a08f06d and 020b09f.

📒 Files selected for processing (1)
  • packages/storage_client/test/client_test.dart

Comment thread packages/storage_client/test/client_test.dart
Comment thread packages/storage_client/test/client_test.dart Outdated
Comment thread packages/storage_client/test/client_test.dart
@spydon
spydon merged commit e1ebfb0 into main Aug 5, 2026
40 checks passed
@spydon
spydon deleted the fix/storage-test-bucket-cleanup branch August 5, 2026 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

storage This issue or pull request is related to storage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants