Skip to content

test: expand unit coverage for supabase_common and storage_client types#1595

Merged
spydon merged 1 commit into
mainfrom
test/improve-coverage-common-storage
Jul 15, 2026
Merged

test: expand unit coverage for supabase_common and storage_client types#1595
spydon merged 1 commit into
mainfrom
test/improve-coverage-common-storage

Conversation

@spydon

@spydon spydon commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

What

Fills genuine, server-free unit coverage gaps found by measuring actual line coverage (dart test --coverage + format_coverage) across the self-contained packages.

supabase_common → now 100% line coverage on every file

  • test/supabase_common_test.dart:
    • FetchOptions group (defaults + provided values, previously 0%).
    • platform info group covering the dart:io getters (platform_io.dart, previously 0%).
    • Extra ReplaySubject cases: async error replay, sync value replay, setter-assigned onListen/onCancel, and the onPause/onResume no-ops.
  • test/retry_test.dart: covers the onRetry callback (the one uncovered line in retry.dart).

storage_client/lib/src/types.dart → 86.8% to ~99%

New test/types_test.dart (29 tests): Bucket/FileObject/FileObjectV2/PaginatedListResult fromJson (including the FormatException path and defaults), the toMap/toQueryParameters serializers, SignedUrl equality/hashCode/copyWith/toString, exhaustive switch matching over the sealed SignedUrlResult, StorageException, TransformOptions.toQueryParams, DownloadBehavior and StorageRetryController.

All new and modified tests pass and are formatted. No production code changed.

Issues surfaced while writing these tests

  1. Dead defensive branch in storage_client/lib/src/fetch.dart_handleError's else branch (handling a non-http.Response error) is unreachable; both call sites only ever pass an http.Response. Left as-is here; flagging for follow-up.
  2. ReplaySubject sync-replay quirk — a sync: true subject delivers live events synchronously but replays the latest buffered event to a late subscriber asynchronously (because Stream.multi schedules its generator). Tests await accordingly.
  3. Pre-existing integration failures (unrelated to this PR)storage_client/test/client_test.dart and 62 postgrest "Default http client" tests require a running/clean local server; the additions here are all offline/mock-based.

Bring supabase_common to full line coverage by testing FetchOptions
defaults, the dart:io platform getters, the remaining ReplaySubject
branches (async error replay, sync value replay, setter-assigned hooks)
and the retry onRetry callback.

Add a storage_client types_test covering fromJson parsing, query/map
serializers, SignedUrl equality and copyWith, exhaustive matching over
the sealed SignedUrlResult, StorageException, TransformOptions,
DownloadBehavior and StorageRetryController.
@spydon
spydon requested a review from a team as a code owner July 14, 2026 07:36

@QuintinWillison QuintinWillison left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Any PR that straight up adds more tests pretty much always gets my instant approval! 💪

@spydon
spydon merged commit 73acbc9 into main Jul 15, 2026
36 checks passed
@spydon
spydon deleted the test/improve-coverage-common-storage branch July 15, 2026 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants