History

Type the platform-view write-refusal helper against surface error unions

Rhys Sullivan committed 3 months ago

Commit 7f3cf091 parent f1d58ba1 file · +9 −6Browse files

Unified · Split

packages/core/sdk/src/platform-view.test.ts+9−6
@@ -406,17 +406,20 @@ describe("platform view — admin.listSubjects", () => { · 405 unmodified lines
406406 * missing credential provider), and such a failure would let the assertion pass
407407 * without the policy ever having been consulted.
408408 */
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(
413418 Effect.flatMap(() => Effect.die("expected the platform view to refuse this write")),
414419 Effect.catchTag("StorageError", (error: StorageError) => {
415420 expect(error.message).toContain("read-only");
416421 return Effect.void;
417422 }),
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.
420423 Effect.orDie,
421424 );
422425