Skip to content

Commit

Permalink
4356 Stream.orDie effectful failure tests
Browse files Browse the repository at this point in the history
Added tests for issue Effect-TS#4356

Effectful failures or not handled by the orDie

TODO: Add stream error from asyncIterator generator as well since that won't be caught either
  • Loading branch information
arijoon committed Jan 28, 2025
1 parent 7437058 commit 33d3f8b
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions packages/effect/test/Stream/error-handling.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,4 +359,29 @@ describe("Stream", () => {
)
assert.deepStrictEqual(Array.from(result), [1, 2])
}))

it.effect("orDie with Stream.fail", () =>
Effect.gen(function*($) {
const stream = pipe(Stream.succeed(1), Stream.concat(Stream.fail("boom")))
const result = yield* $(
stream,
Stream.orDie,
Stream.runCollect,
Effect.catchAllDefect(() => Effect.succeed("EXPECTED" as const))
)
assert.equal(result, "EXPECTED")
}))

it.effect("orDie effectful failure", () =>
Effect.gen(function*($) {
const stream = Stream.succeed(1)
const result = yield* $(
stream,
Stream.mapEffect(() => Effect.fail("UNEXPECTED" as const)),
Stream.orDie,
Stream.runCollect,
Effect.catchAllDefect(() => Effect.succeed("EXPECTED" as const))
)
assert.equal(result, "EXPECTED")
}))
})

0 comments on commit 33d3f8b

Please sign in to comment.