| 1 | import { assert, it } from "@effect/vitest"; |
| 2 | import * as Effect from "effect/Effect"; |
| 3 | import * as Schema from "effect/Schema"; |
| 4 | |
| 5 | import { OrchestrationDispatchCommandError } from "./orchestrationDispatch.ts"; |
| 6 | |
| 7 | const decodeDispatchCommandError = Schema.decodeUnknownEffect(OrchestrationDispatchCommandError); |
| 8 | |
| 9 | it.effect("decodes a dispatch error after its bootstrap thread was deleted", () => |
| 10 | Effect.gen(function* () { |
| 11 | const error = yield* decodeDispatchCommandError({ |
| 12 | _tag: "OrchestrationDispatchCommandError", |
| 13 | message: "Failed to create worktree.", |
| 14 | bootstrapThreadDisposition: "deleted", |
| 15 | }); |
| 16 | |
| 17 | assert.strictEqual(error.bootstrapThreadDisposition, "deleted"); |
| 18 | }), |
| 19 | ); |
| 20 | |
| 21 | it.effect("decodes a dispatch error before its bootstrap thread was created", () => |
| 22 | Effect.gen(function* () { |
| 23 | const error = yield* decodeDispatchCommandError({ |
| 24 | _tag: "OrchestrationDispatchCommandError", |
| 25 | message: "A separate worktree requires a base commit.", |
| 26 | bootstrapThreadDisposition: "not-created", |
| 27 | }); |
| 28 | |
| 29 | assert.strictEqual(error.bootstrapThreadDisposition, "not-created"); |
| 30 | }), |
| 31 | ); |