@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 06:00 UTC

main
ts 27 lines 1004 Bytes
Raw
1 import * as BunStream from "@effect/platform-bun/BunStream"
2 import { assert, describe, it } from "@effect/vitest"
3 import * as Cause from "effect/Cause"
4 import * as Effect from "effect/Effect"
5 import * as Exit from "effect/Exit"
6 import * as Stream from "effect/Stream"
7
8 describe("BunStream", () => {
9 it.effect("preserves mapped failures from errored readable streams", () =>
10 Effect.gen(function*() {
11 const exit = yield* BunStream.fromReadableStream({
12 evaluate: () =>
13 new ReadableStream<number>({
14 start(controller) {
15 controller.error(new Error("boom"))
16 }
17 }),
18 onError: (error) => new Error(`mapped: ${(error as Error).message}`)
19 }).pipe(Stream.runDrain, Effect.exit)
20
21 assert.isTrue(Exit.isFailure(exit))
22 if (Exit.isFailure(exit)) {
23 assert.isTrue(exit.cause.reasons.every(Cause.isFailReason))
24 assert.deepStrictEqual(Cause.squash(exit.cause), new Error("mapped: boom"))
25 }
26 }))
27 })