test(storage): remove the buckets the suite creates - #1641
Conversation
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.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe 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. ChangesStorage test isolation
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (1)
packages/storage_client/test/client_test.dart
Stacked on #1640, since it touches the same file.
The storage suite created buckets and never removed them, while
List bucketsasserted the total bucket count. A second run against the same stack therefore failed twice over: the listing saw the leftovers, andCreate new public buckethit a 409 because it uses a fixed name. Only CI got away with it, because every job starts a fresh stack.List bucketsnow 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