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