1import { assert, it } from "@effect/vitest";
2import * as Effect from "effect/Effect";
3import * as Schema from "effect/Schema";
4
5import { OrchestrationDispatchCommandError } from "./orchestrationDispatch.ts";
6
7const decodeDispatchCommandError = Schema.decodeUnknownEffect(OrchestrationDispatchCommandError);
8
9it.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
21it.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);