@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
ts 68 lines 2.73 KB
Raw
1 import * as Prisma from "@alchemy.run/prisma";
2 import { expect } from "@alchemy.run/test";
3 import * as Test from "@alchemy.run/test/Alchemy";
4 import { getProject, getService } from "@distilled.cloud/prisma/management";
5 import * as Effect from "effect/Effect";
6 import * as HttpClient from "effect/http/HttpClient";
7 import { MinimumLogLevel } from "effect/References";
8 import * as Schedule from "effect/Schedule";
9 import { materializeIsolatedProject, removeIsolatedProject } from "../IsolatedProject.ts";
10 import IsolatedProjectCompute, { project } from "./fixtures/isolated-project-compute.ts";
11
12 const { test } = Test.make({ providers: Prisma.providers() });
13
14 const logLevel = Effect.provideService(MinimumLogLevel, process.env.DEBUG ? "Debug" : "Info");
15
16 // Live proof that the Prisma Compute bun bootstrap boots when the app's
17 // `main` lives in an isolated project (see test/IsolatedProject.ts) — the
18 // bundle `cwd` resolves none of alchemy's dependencies, so the bootstrap's
19 // `@effect/platform-bun` / `alchemy/*` imports must be bundled by the
20 // virtual-entry plugin rather than found from the project root. With them
21 // left external bun dies at module load and the app never answers.
22 test.provider(
23 "app bundled from an isolated project serves HTTP",
24 (stack) =>
25 Effect.gen(function* () {
26 yield* materializeIsolatedProject(project);
27 yield* stack.destroy();
28
29 try {
30 const app = yield* stack.deploy(
31 Effect.gen(function* () {
32 return yield* IsolatedProjectCompute;
33 }),
34 );
35 expect(app.url).toBeTruthy();
36
37 const health = yield* HttpClient.get(new URL("/health", app.url)).pipe(
38 Effect.flatMap((res) =>
39 res.status === 200
40 ? res.json
41 : Effect.fail(new Error(`/health returned ${res.status}`)),
42 ),
43 Effect.retry({ schedule: Schedule.spaced("2 seconds"), times: 30 }),
44 );
45 expect(health).toEqual({ ok: true });
46
47 yield* stack.destroy();
48 const projectGone = yield* getProject({ id: app.projectId }).pipe(
49 Effect.as(false),
50 Effect.catchTag("NotFound", () => Effect.succeed(true)),
51 );
52 const appGone = yield* getService({ serviceId: app.appId }).pipe(
53 Effect.as(false),
54 Effect.catchTag("NotFound", () => Effect.succeed(true)),
55 );
56 expect(projectGone).toBe(true);
57 expect(appGone).toBe(true);
58 } finally {
59 yield* stack.destroy().pipe(Effect.ignore);
60 yield* removeIsolatedProject(project);
61 }
62 }).pipe(logLevel),
63 // One Prisma Compute deploy alone can take the full 600s.
64 {
65 tags: ["provider:prisma", "provider:prisma:compute", "provider:prisma:project", "live"],
66 timeout: 1_200_000,
67 },
68 );