@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.08 KB
Raw
1 import * as Cloudflare from "@alchemy.run/cloudflare";
2 import * as Planetscale from "@alchemy.run/planetscale";
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 PlanetscaleHostStack from "./fixtures/pshost/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(), Planetscale.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 * PlanetScale is mode-agnostic like Neon: `alchemy dev` still points the
24 * container at `*.psdb.cloud` (pooled PSBouncer). Same #1334 path as Prisma
25 * and Neon — rewrite must be a no-op, TCP from the container must succeed.
26 */
27 describe.skipIf(!process.env.PLANETSCALE_TEST)(
28 "local container reaches PlanetScale Postgres",
29 {
30 tags: [
31 "provider:cloudflare",
32 "provider:cloudflare:container",
33 "provider:cloudflare:worker",
34 "provider:planetscale",
35 "provider:planetscale:postgres",
36 "live",
37 ],
38 },
39 () => {
40 const stack = beforeAll(deploy(PlanetscaleHostStack), {
41 timeout: HOOK_TIMEOUT,
42 });
43 afterAll.skipIf(!!process.env.NO_DESTROY)(destroy(PlanetscaleHostStack), {
44 timeout: HOOK_TIMEOUT,
45 });
46
47 test(
48 "container DATABASE_URL keeps the PlanetScale 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(/psdb\.cloud$/);
56 });
57 }).pipe(logLevel),
58 { timeout: TEST_TIMEOUT },
59 );
60 },
61 );