@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 49 lines 1.47 KB
Raw
1 import { expect } from "bun:test";
2 import * as Railway from "@alchemy.run/railway";
3 import * as Test from "@alchemy.run/test/Bun";
4 import * as Alchemy from "alchemy";
5 import * as Effect from "effect/Effect";
6 import * as HttpClient from "effect/http/HttpClient";
7 import * as Schedule from "effect/Schedule";
8 import Stack from "../alchemy.run.ts";
9
10 const { test, beforeAll, afterAll, deploy, destroy } = Test.make({
11 providers: Railway.providers(),
12 state: Alchemy.localState(),
13 profile: process.env.ALCHEMY_PROFILE,
14 });
15
16 const fetchOk = (url: string) =>
17 Effect.gen(function* () {
18 const client = yield* HttpClient.HttpClient;
19 return yield* client.get(url).pipe(
20 Effect.flatMap((res) =>
21 res.status === 200 ? Effect.succeed(res) : Effect.fail(new Error(`HTTP ${res.status}`)),
22 ),
23 Effect.retry({
24 schedule: Schedule.exponential("500 millis"),
25 times: 10,
26 }),
27 );
28 });
29
30 const stack = beforeAll(deploy(Stack), { timeout: 180_000 });
31
32 afterAll.skipIf(!!process.env.NO_DESTROY)(destroy(Stack), {
33 timeout: 120_000,
34 });
35
36 test(
37 "deploys http-echo on a Service and serves over up.railway.app",
38 Effect.gen(function* () {
39 const out = yield* stack;
40 expect(out.url).toBeString();
41 expect(out.url).toMatch(/^https:\/\/.+\.up\.railway\.app$/);
42 expect(out.projectId).toBeString();
43 expect(out.serviceId).toBeString();
44
45 const response = yield* fetchOk(out.url!);
46 expect(response.status).toBe(200);
47 }),
48 { timeout: 120_000 },
49 );