The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import { IssueTrackerKind, ThreadId } from "@t3tools/contracts"; |
| 2 | import { describe, expect, it } from "@effect/vitest"; |
| 3 | import * as SecureRandom from "effect/crypto/SecureRandom"; |
| 4 | import * as Effect from "effect/Effect"; |
| 5 | import * as Layer from "effect/Layer"; |
| 6 | |
| 7 | import * as SqlitePersistence from "../persistence/Sqlite.ts"; |
| 8 | import * as Orchestrator from "./Orchestrator.ts"; |
| 9 | import * as ThreadIssueService from "./ThreadIssueService.ts"; |
| 10 | |
| 11 | const THREAD_ID = ThreadId.make("thread-1"); |
| 12 | |
| 13 | describe("ThreadIssueService", () => { |
| 14 | it.effect("fails an unlink whose thread cannot be read instead of reporting it unlinked", () => |
| 15 | Effect.gen(function* () { |
| 16 | const service = yield* ThreadIssueService.ThreadIssueService; |
| 17 | const error = yield* service |
| 18 | .unlink({ |
| 19 | threadId: THREAD_ID, |
| 20 | key: { |
| 21 | tracker: IssueTrackerKind.make("github"), |
| 22 | host: "github.com", |
| 23 | scope: "t3tools/t3code", |
| 24 | key: "7", |
| 25 | }, |
| 26 | }) |
| 27 | .pipe(Effect.flip); |
| 28 | expect(error).toMatchObject({ _tag: "OrchestratorProjectionError", threadId: THREAD_ID }); |
| 29 | }).pipe( |
| 30 | Effect.provide( |
| 31 | ThreadIssueService.layer.pipe( |
| 32 | Layer.provide( |
| 33 | Layer.mergeAll( |
| 34 | SqlitePersistence.layerMemory, |
| 35 | Layer.mock(Orchestrator.OrchestratorV2)({ |
| 36 | getThreadShell: (threadId) => |
| 37 | Effect.fail(new Orchestrator.OrchestratorProjectionError({ threadId })), |
| 38 | }), |
| 39 | Layer.succeed( |
| 40 | SecureRandom.SecureRandom, |
| 41 | SecureRandom.make((size) => new Uint8Array(size).fill(7)), |
| 42 | ), |
| 43 | ), |
| 44 | ), |
| 45 | ), |
| 46 | ), |
| 47 | ), |
| 48 | ); |
| 49 | }); |