@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 97 lines 3.38 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_COMPUTE_INTERCONNECT && !process.env.FAST;
15
16 const waitUntilGone = (interconnectAttachmentGroup: string) =>
17 GcpEnvironment.current.pipe(
18 Effect.flatMap(({ project }) =>
19 compute
20 .getInterconnectAttachmentGroups({
21 project,
22 interconnectAttachmentGroup,
23 })
24 .pipe(
25 Effect.as("found" as const),
26 Effect.catchTag("NotFound", () => Effect.succeed("gone" as const)),
27 Effect.repeat({
28 schedule: Schedule.spaced("1 second"),
29 until: (status) => status === "gone",
30 times: 10,
31 }),
32 ),
33 ),
34 );
35
36 test.provider(
37 "getInterconnectAttachmentGroups on a missing group fails with NotFound",
38 (stack) =>
39 Effect.gen(function* () {
40 const { project } = yield* GcpEnvironment.current;
41 yield* stack.destroy();
42
43 const error = yield* Effect.flip(
44 compute.getInterconnectAttachmentGroups({
45 project,
46 interconnectAttachmentGroup: "alchemy-missing-iag",
47 }),
48 );
49 expect(error._tag).toBe("NotFound");
50
51 yield* stack.destroy();
52 }).pipe(logLevel),
53 { tags: ["provider:gcp", "provider:gcp:compute", "live"], timeout: 90_000 },
54 );
55
56 test.provider.skipIf(!runLifecycle)(
57 "create, update, and delete an interconnect attachment group",
58 (stack) =>
59 Effect.gen(function* () {
60 yield* stack.destroy();
61
62 const created = yield* stack.deploy(
63 Effect.gen(function* () {
64 return yield* GCP.Compute.InterconnectAttachmentGroup("Vlans", {
65 description: "dev vlan attachments",
66 intent: { availabilitySla: "NO_SLA" },
67 });
68 }),
69 );
70
71 expect(created.interconnectAttachmentGroupName).toEqual(expect.any(String));
72 expect(created.description).toEqual("dev vlan attachments");
73
74 const fetched = yield* compute.getInterconnectAttachmentGroups({
75 project: created.project,
76 interconnectAttachmentGroup: created.interconnectAttachmentGroupName,
77 });
78 expect(fetched.name).toEqual(created.interconnectAttachmentGroupName);
79 expect(fetched.description).toContain("[alchemy ");
80
81 const updated = yield* stack.deploy(
82 Effect.gen(function* () {
83 return yield* GCP.Compute.InterconnectAttachmentGroup("Vlans", {
84 interconnectAttachmentGroupName: created.interconnectAttachmentGroupName,
85 description: "updated vlan attachments",
86 intent: { availabilitySla: "NO_SLA" },
87 });
88 }),
89 );
90 expect(updated.description).toEqual("updated vlan attachments");
91
92 yield* stack.destroy();
93 const gone = yield* waitUntilGone(created.interconnectAttachmentGroupName);
94 expect(gone).toEqual("gone");
95 }).pipe(logLevel),
96 { tags: ["provider:gcp", "provider:gcp:compute", "live"], timeout: 90_000 },
97 );