@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.03 KB
Raw
1 import * as Cloudflare from "@alchemy.run/cloudflare";
2 import * as Neon from "@alchemy.run/neon";
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 NeonHostStack from "./fixtures/neonhost/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(), Neon.providers()),
13 state: Cloudflare.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 * Neon is mode-agnostic: `alchemy dev` still hands the container a cloud
24 * `*.neon.tech` URL. The loopback rewrite must not touch it, and with
25 * `enableInternet` the container must be able to dial it — the same
26 * #1334 "container reaches a SQL database" path as Prisma, minus a local
27 * emulator.
28 */
29 describe(
30 "local container reaches Neon Postgres",
31 {
32 tags: [
33 "provider:cloudflare",
34 "provider:cloudflare:container",
35 "provider:cloudflare:worker",
36 "provider:neon",
37 "provider:neon:project",
38 "live",
39 ],
40 },
41 () => {
42 const stack = beforeAll(deploy(NeonHostStack), { timeout: HOOK_TIMEOUT });
43 afterAll.skipIf(!!process.env.NO_DESTROY)(destroy(NeonHostStack), {
44 timeout: HOOK_TIMEOUT,
45 });
46
47 test(
48 "container DATABASE_URL keeps the Neon host and reaches it",
49 Effect.gen(function* () {
50 const { url } = yield* stack;
51 yield* expectDatabaseReachable(url, (hostname) => {
52 expect(hostname).not.toBe("localhost");
53 expect(hostname).not.toBe("127.0.0.1");
54 expect(hostname).not.toContain("host.docker.localhost");
55 expect(hostname).toMatch(/neon\.tech$/);
56 });
57 }).pipe(logLevel),
58 { timeout: TEST_TIMEOUT },
59 );
60 },
61 );