@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 79 lines 2.78 KB
Raw
1 import * as GCP from "@alchemy.run/gcp";
2 import { GcpEnvironment } from "@alchemy.run/gcp/Environment";
3 import { expect } from "@alchemy.run/test";
4 import * as Test from "@alchemy.run/test/Alchemy";
5 import * as compute from "@distilled.cloud/gcp/compute_v1";
6 import * as Effect from "effect/Effect";
7 import { MinimumLogLevel } from "effect/References";
8 import * as Schedule from "effect/Schedule";
9
10 const { test } = Test.make({ providers: GCP.providers() });
11
12 const logLevel = Effect.provideService(MinimumLogLevel, process.env.DEBUG ? "Debug" : "Info");
13
14 const runLifecycle = !!process.env.GCP_TEST_BYOIP && !process.env.FAST;
15
16 const ipCidrRange = process.env.GCP_TEST_PAP_RANGE ?? "203.0.113.0/24";
17 const dnsVerificationIp = process.env.GCP_TEST_PAP_DNS_IP ?? "203.0.113.1";
18
19 const waitUntilGone = (project: string, publicAdvertisedPrefix: string) =>
20 compute.getPublicAdvertisedPrefixes({ project, publicAdvertisedPrefix }).pipe(
21 Effect.as("found" as const),
22 Effect.catchTag("NotFound", () => Effect.succeed("gone" as const)),
23 Effect.repeat({
24 schedule: Schedule.spaced("2 seconds"),
25 until: (status) => status === "gone",
26 times: 10,
27 }),
28 );
29
30 test.provider.skipIf(!runLifecycle)(
31 "create, update, and delete a public advertised prefix",
32 (stack) =>
33 Effect.gen(function* () {
34 yield* stack.destroy();
35
36 const created = yield* stack.deploy(
37 Effect.gen(function* () {
38 return yield* GCP.Compute.PublicAdvertisedPrefix("Byoip", {
39 ipCidrRange,
40 dnsVerificationIp,
41 pdpScope: "REGIONAL",
42 description: "lab prefix",
43 });
44 }),
45 );
46
47 expect(created.prefixName).toEqual(expect.any(String));
48 expect(created.ipCidrRange).toEqual(ipCidrRange);
49 expect(created.description).toEqual("lab prefix");
50
51 const fetched = yield* compute.getPublicAdvertisedPrefixes({
52 project: created.project,
53 publicAdvertisedPrefix: created.prefixName,
54 });
55 expect(fetched.name).toEqual(created.prefixName);
56 expect(fetched.description).toContain("[alchemy ");
57
58 const updated = yield* stack.deploy(
59 Effect.gen(function* () {
60 return yield* GCP.Compute.PublicAdvertisedPrefix("Byoip", {
61 prefixName: created.prefixName,
62 ipCidrRange,
63 dnsVerificationIp,
64 pdpScope: "REGIONAL",
65 description: "updated prefix",
66 });
67 }),
68 );
69
70 expect(updated.prefixName).toEqual(created.prefixName);
71 expect(updated.description).toEqual("updated prefix");
72
73 yield* stack.destroy();
74
75 const gone = yield* waitUntilGone(created.project, created.prefixName);
76 expect(gone).toEqual("gone");
77 }).pipe(logLevel),
78 { tags: ["provider:gcp", "provider:gcp:compute", "live"], timeout: 90_000 },
79 );