Commit 623777b
authored
test: use proper matchers in tests (#1437)
## What kind of change does this PR introduce?
Test quality cleanup. No production code changes; only test files are
touched.
## What is the current behavior?
Several test suites used non-idiomatic assertions:
- boolean-literal expectations, e.g. `expect(x, true)` / `expect(x,
false)`
- equality checks done inside the actual argument, e.g. `expect(a == b,
true)`
- length-zero emptiness checks, e.g. `expect(x.length, 0)`
- exception assertions written as `try { await ...; fail('...'); } catch
(e) { expect(e, ...) }`
## What is the new behavior?
These are replaced with the proper matchers across all packages:
- `expect(x, isTrue)` / `expect(x, isFalse)`
- `expect(a, b)` / `expect(a, isNot(b))`
- `expect(x, isEmpty)`
- `expectLater(() => ..., throwsA(isA<T>().having((e) => e.field,
'field', value)))`
Approximate counts: ~47 boolean matchers, ~22 direct equality, ~8
emptiness, ~43 exception conversions across 22 test files in
functions_client, gotrue, postgrest, realtime_client, storage_client,
supabase, and supabase_flutter.
A few `fail()` calls were intentionally left in place because they are
not exception-testing patterns (one sits inside an `await for` stream
loop, two assert that a download succeeds after copy/move).
## How was the change verified?
- `dart analyze` / `flutter analyze` on every affected package's `test/`
directory: no issues.
- `dart format` on all changed files: already conformant.
- All mock-based suites pass. Server-dependent integration suites were
not run locally but analyze cleanly; the conversions are mechanical and
preserve assertion meaning.1 parent 9e71a24 commit 623777b
21 files changed
Lines changed: 345 additions & 422 deletions
File tree
- packages
- functions_client/test
- gotrue/test
- src
- postgrest/test
- realtime_client/test
- storage_client/test
- supabase_flutter/test
- supabase/test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
29 | 28 | | |
30 | 29 | | |
31 | 30 | | |
| |||
411 | 410 | | |
412 | 411 | | |
413 | 412 | | |
414 | | - | |
415 | | - | |
416 | | - | |
417 | | - | |
418 | | - | |
419 | | - | |
420 | | - | |
421 | | - | |
422 | | - | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
423 | 421 | | |
424 | 422 | | |
425 | 423 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
116 | 112 | | |
117 | 113 | | |
118 | 114 | | |
| |||
125 | 121 | | |
126 | 122 | | |
127 | 123 | | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
132 | 128 | | |
133 | 129 | | |
134 | 130 | | |
| |||
138 | 134 | | |
139 | 135 | | |
140 | 136 | | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
153 | 144 | | |
154 | 145 | | |
155 | 146 | | |
| |||
442 | 433 | | |
443 | 434 | | |
444 | 435 | | |
445 | | - | |
446 | | - | |
447 | | - | |
448 | | - | |
449 | | - | |
450 | | - | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
451 | 441 | | |
452 | 442 | | |
453 | 443 | | |
| |||
473 | 463 | | |
474 | 464 | | |
475 | 465 | | |
476 | | - | |
477 | | - | |
| 466 | + | |
| 467 | + | |
478 | 468 | | |
479 | 469 | | |
480 | | - | |
481 | | - | |
482 | | - | |
483 | | - | |
484 | | - | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
485 | 474 | | |
486 | 475 | | |
487 | 476 | | |
| |||
686 | 675 | | |
687 | 676 | | |
688 | 677 | | |
689 | | - | |
690 | | - | |
691 | | - | |
692 | | - | |
693 | | - | |
694 | | - | |
695 | | - | |
696 | | - | |
697 | | - | |
698 | | - | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
699 | 683 | | |
700 | 684 | | |
701 | 685 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
83 | 81 | | |
0 commit comments