Unified · Split
| @@ -406,17 +406,20 @@ describe("platform view — admin.listSubjects", () => { · 405 unmodified lines | ||
| 406 | 406 | * missing credential provider), and such a failure would let the assertion pass |
| 407 | 407 | * without the policy ever having been consulted. |
| 408 | 408 | */ |
| 409 | −const expectWriteRefused = <A, E extends { readonly _tag: string }>(effect: Effect.Effect<A, E>) => | |
| 410 | − effect.pipe( | |
| 411 | − // A write that SUCCEEDS dies here rather than reaching an assertion, so the | |
| 412 | − // hole this pins can never be reported as a pass. | |
| 409 | +const expectWriteRefused = <A, E extends { readonly _tag: string }>( | |
| 410 | + effect: Effect.Effect<A, E | StorageError>, | |
| 411 | +) => | |
| 412 | + // The surfaces under test fail with different unions (StorageFailure, | |
| 413 | + // ConnectionNotFoundError, …). The refusal this pins is always a | |
| 414 | + // StorageError, so the effect is widened for the catch; `orDie` below still | |
| 415 | + // turns every OTHER tag into a test failure, and a write that SUCCEEDS dies | |
| 416 | + // rather than reaching an assertion — so the hole can never pass silently. | |
| 417 | + (effect as Effect.Effect<A, StorageError>).pipe( | |
| 413 | 418 | Effect.flatMap(() => Effect.die("expected the platform view to refuse this write")), |
| 414 | 419 | Effect.catchTag("StorageError", (error: StorageError) => { |
| 415 | 420 | expect(error.message).toContain("read-only"); |
| 416 | 421 | return Effect.void; |
| 417 | 422 | }), |
| 418 | − // Any OTHER failure means the call never reached the owner policy — an | |
| 419 | − // absent row, a missing provider — which would leave the refusal untested. | |
| 420 | 423 | Effect.orDie, |
| 421 | 424 | ); |
| 422 | 425 | |