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