@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, 06:00 UTC

main
ts 61 lines 2.12 KB
Raw
1 import * as Cloudflare from "@alchemy.run/cloudflare";
2 import * as Prisma from "@alchemy.run/prisma";
3 import { describe, expect } from "@alchemy.run/test";
4 import * as Test from "@alchemy.run/test/Alchemy";
5 import * as Effect from "effect/Effect";
6 import * as Layer from "effect/Layer";
7 import { MinimumLogLevel } from "effect/References";
8 import PrismaHostStack, { state } from "./fixtures/prismahost/stack.ts";
9 import { expectDatabaseReachable } from "./fixtures/sqlreach/expect.ts";
10
11 const { test, beforeAll, afterAll, deploy, destroy } = Test.make({
12 providers: Layer.merge(Cloudflare.providers(), Prisma.providers()),
13 state,
14 dev: true,
15 });
16
17 const logLevel = Effect.provideService(MinimumLogLevel, process.env.DEBUG ? "Debug" : "Info");
18
19 const HOOK_TIMEOUT = 300_000;
20 const TEST_TIMEOUT = 240_000;
21
22 /**
23 * Regression for alchemy-run/alchemy#1334 on Linux: an arbitrary image given
24 * a local Prisma `DATABASE_URL` (`postgres://…@127.0.0.1:…`) must be able to
25 * reach `@prisma/dev` from inside the container. host-gateway rewrites the
26 * hostname, but the server still has to accept connections on the Docker
27 * bridge — a 127.0.0.1 listener times out with
28 * `dial error: timeout` to `172.17.0.1`.
29 */
30 describe(
31 "local container reaches Prisma Postgres",
32 {
33 tags: [
34 "provider:cloudflare",
35 "provider:cloudflare:container",
36 "provider:cloudflare:worker",
37 "provider:prisma",
38 "provider:prisma:connection",
39 "provider:prisma:project",
40 ],
41 },
42 () => {
43 const stack = beforeAll(deploy(PrismaHostStack), { timeout: HOOK_TIMEOUT });
44 afterAll.skipIf(!!process.env.NO_DESTROY)(destroy(PrismaHostStack), {
45 timeout: HOOK_TIMEOUT,
46 });
47
48 test(
49 "container DATABASE_URL is rewritten once and reaches the host Prisma",
50 Effect.gen(function* () {
51 const { url } = yield* stack;
52 yield* expectDatabaseReachable(url, (hostname) => {
53 expect(hostname).not.toBe("localhost");
54 expect(hostname).not.toBe("127.0.0.1");
55 expect(hostname).toContain("localhost");
56 });
57 }).pipe(logLevel),
58 { tags: ["local"], timeout: TEST_TIMEOUT },
59 );
60 },
61 );