Skip to content

test: remove abbreviations and code smells across package tests#1584

Merged
spydon merged 4 commits into
mainfrom
lukasklingsbo/sdk-1290-clean-up-package-tests-remove-abbreviations-and-code-smells
Jul 10, 2026
Merged

test: remove abbreviations and code smells across package tests#1584
spydon merged 4 commits into
mainfrom
lukasklingsbo/sdk-1290-clean-up-package-tests-remove-abbreviations-and-code-smells

Conversation

@spydon

@spydon spydon commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

What

Cleans up the test suites across every package. No production (lib/) changes.

  • Abbreviations removed in test-local identifiers: res/getRes/… → response/result, reqrequest, paramsparameters, msgmessage, e/errerror, connconnection, dbdatabase, ataccessToken, sigsignature, subsubscription, and similar. Public API names, named arguments, JSON/map keys and conventional acronyms (id, url, jwt, otp, pkce, ws, …) are left untouched.
  • Weak assertions strengthened with proper matchers: isNotNull, isEmpty, isTrue/isFalse, hasLength, contains, isA<T>(), endsWith, isNot(contains(...)). Redundant .toString()/casts and a pointless cascade removed.
  • Idiomatic throw assertions: converted try { await op } catch (e) { expect(e, isA<X>()) } and closure-wrapped expectLater(() => future, throwsA(...)) to expectLater(future, throwsA(...)) (69 sites). Genuinely synchronous expect(() => syncCall(), throwsX) and mockito when/verify closures were left as-is.
  • Stale phone-auth tests fixed: the two gotrue "should fail because Twilio is not setup" tests were silently passing as no-ops (a try/catch swallowed the non-exception). The test stack deliberately enables phone auth, so they now assert the real success behavior.
  • Useless/duplicate tests removed (7):
    • gotrue: four identical same() reference-equality tautologies (session, auth_exception, user, user_identity).
    • realtime: socket_test "calls callback" (incremented a counter unconditionally, asserted nothing real).
    • postgrest: "bulk insert with one row uses default value" (exact duplicate).
    • storage: "getPublicUrl leaves the URL unchanged when download is null" (byte-for-byte duplicate).

Testing

All package suites pass against a local Supabase stack: gotrue 446, realtime 182, postgrest 177, storage 110, functions 45, supabase 83, supabase_common 33, supabase_flutter 63, yet_another_json_isolate 4. dart analyze clean, dart format applied.

Resolves SDK-1290.

Rename test-local identifiers to full words (response, request, message,
error, configuration, connection, and similar), leaving public API names,
named arguments, JSON keys and conventional acronyms untouched. Replace
weak assertions with proper matchers, remove redundant casts and toString
calls, and delete useless or duplicate tests.

Convert try/catch throw-assertions and closure-wrapped async expectLater
calls to the idiomatic expectLater(future, throwsA(...)) form, and rewrite
the stale phone auth tests to assert their real success behavior against
the configured stack.
@spydon spydon requested a review from a team as a code owner July 10, 2026 14:21
spydon added 2 commits July 10, 2026 16:33
…0-clean-up-package-tests-remove-abbreviations-and-code-smells

# Conflicts:
#	packages/gotrue/test/src/types/user_test.dart
#	packages/postgrest/test/basic_test.dart
#	packages/postgrest/test/filter_test.dart
#	packages/postgrest/test/transforms_test.dart
Convert smoke tests that only awaited an async call to
expect(future, completes), and rename them to state the expected
outcome.
@spydon spydon enabled auto-merge (squash) July 10, 2026 14:48
Use the closure form for expectLater on Postgrest builders (which
implement Future but are not recognized as Future by the linter), keep
the bare await for the Postgrest completes smoke tests, and drop the
now-unnecessary async from the initialization tests.
@spydon spydon merged commit c3e3602 into main Jul 10, 2026
33 checks passed
@spydon spydon deleted the lukasklingsbo/sdk-1290-clean-up-package-tests-remove-abbreviations-and-code-smells branch July 10, 2026 15:01
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