| 1 | import { OrchestrationDispatchCommandError } from "@t3tools/contracts"; |
| 2 | import { describe, expect, it } from "vite-plus/test"; |
| 3 | |
| 4 | import { wasBootstrapThreadDeleted, wasBootstrapThreadNotCreated } from "./orchestration.ts"; |
| 5 | |
| 6 | describe("wasBootstrapThreadDeleted", () => { |
| 7 | it("accepts only a confirmed deleted bootstrap thread", () => { |
| 8 | expect( |
| 9 | wasBootstrapThreadDeleted( |
| 10 | new OrchestrationDispatchCommandError({ |
| 11 | message: "Failed to create worktree.", |
| 12 | bootstrapThreadDisposition: "deleted", |
| 13 | }), |
| 14 | ), |
| 15 | ).toBe(true); |
| 16 | expect( |
| 17 | wasBootstrapThreadDeleted( |
| 18 | new OrchestrationDispatchCommandError({ message: "Failed to create worktree." }), |
| 19 | ), |
| 20 | ).toBe(false); |
| 21 | expect(wasBootstrapThreadDeleted(new Error("connection lost"))).toBe(false); |
| 22 | }); |
| 23 | }); |
| 24 | |
| 25 | describe("wasBootstrapThreadNotCreated", () => { |
| 26 | it("accepts only a confirmed never-created bootstrap thread", () => { |
| 27 | const notCreated = new OrchestrationDispatchCommandError({ |
| 28 | message: "A separate worktree requires a base commit.", |
| 29 | bootstrapThreadDisposition: "not-created", |
| 30 | }); |
| 31 | expect(wasBootstrapThreadNotCreated(notCreated)).toBe(true); |
| 32 | expect(wasBootstrapThreadDeleted(notCreated)).toBe(false); |
| 33 | expect( |
| 34 | wasBootstrapThreadNotCreated( |
| 35 | new OrchestrationDispatchCommandError({ |
| 36 | message: "Failed to create worktree.", |
| 37 | bootstrapThreadDisposition: "deleted", |
| 38 | }), |
| 39 | ), |
| 40 | ).toBe(false); |
| 41 | expect( |
| 42 | wasBootstrapThreadNotCreated( |
| 43 | new OrchestrationDispatchCommandError({ |
| 44 | message: "Failed to create worktree.", |
| 45 | }), |
| 46 | ), |
| 47 | ).toBe(false); |
| 48 | expect(wasBootstrapThreadNotCreated(new Error("connection lost"))).toBe(false); |
| 49 | }); |
| 50 | }); |