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 vmwareengine from "@distilled.cloud/gcp/vmwareengine_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 privateCloud = process.env.GCP_TEST_VMWAREENGINE_PRIVATE_CLOUD ?? ""; |
| 15 | const vpcNetworkOf = (project: string) => |
| 16 | process.env.GCP_TEST_VMWAREENGINE_VPC_NETWORK ?? `projects/${project}/global/networks/default`; |
| 17 | |
| 18 | const runLifecycle = |
| 19 | !!process.env.GCP_TEST_VMWAREENGINE && privateCloud.length > 0 && !process.env.FAST; |
| 20 | |
| 21 | const waitUntilGone = (name: string) => |
| 22 | vmwareengine.getProjectsLocationsPrivateCloudsManagementDnsZoneBindings({ name }).pipe( |
| 23 | Effect.as("found" as const), |
| 24 | Effect.catchTag("NotFound", () => Effect.succeed("gone" as const)), |
| 25 | Effect.repeat({ |
| 26 | schedule: Schedule.spaced("2 seconds"), |
| 27 | until: (status) => status === "gone", |
| 28 | times: 10, |
| 29 | }), |
| 30 | ); |
| 31 | |
| 32 | test.provider( |
| 33 | "getProjectsLocationsPrivateCloudsManagementDnsZoneBindings on a missing binding fails with a typed tag", |
| 34 | (stack) => |
| 35 | Effect.gen(function* () { |
| 36 | const { project } = yield* GcpEnvironment.current; |
| 37 | |
| 38 | yield* stack.destroy(); |
| 39 | |
| 40 | const error = yield* Effect.flip( |
| 41 | vmwareengine.getProjectsLocationsPrivateCloudsManagementDnsZoneBindings({ |
| 42 | name: `projects/${project}/locations/us-central1-a/privateClouds/alchemy-pc-missing/managementDnsZoneBindings/alchemy-dns-missing`, |
| 43 | }), |
| 44 | ); |
| 45 | expect(error._tag).toEqual("NotFound"); |
| 46 | |
| 47 | yield* stack.destroy(); |
| 48 | }).pipe(logLevel), |
| 49 | { |
| 50 | tags: ["provider:gcp", "provider:gcp:vmwareengine", "live"], |
| 51 | timeout: 90_000, |
| 52 | }, |
| 53 | ); |
| 54 | |
| 55 | test.provider.skipIf(!runLifecycle)( |
| 56 | "create, update, and delete a management dns zone binding", |
| 57 | (stack) => |
| 58 | Effect.gen(function* () { |
| 59 | const { project } = yield* GcpEnvironment.current; |
| 60 | |
| 61 | yield* stack.destroy(); |
| 62 | |
| 63 | const created = yield* stack.deploy( |
| 64 | Effect.gen(function* () { |
| 65 | return yield* GCP.VMwareEngine.PrivateCloudsManagementDnsZoneBinding("VpcDns", { |
| 66 | privateCloud, |
| 67 | vpcNetwork: vpcNetworkOf(project), |
| 68 | description: "alchemy-test-dns", |
| 69 | }); |
| 70 | }), |
| 71 | ); |
| 72 | |
| 73 | expect(created.name).toContain("/managementDnsZoneBindings/"); |
| 74 | expect(created.privateCloud).toEqual(privateCloud.replace(/\/+$/, "")); |
| 75 | expect(created.description).toEqual("alchemy-test-dns"); |
| 76 | expect(created.createTime).toEqual(expect.any(String)); |
| 77 | |
| 78 | const fetched = |
| 79 | yield* vmwareengine.getProjectsLocationsPrivateCloudsManagementDnsZoneBindings({ |
| 80 | name: created.name, |
| 81 | }); |
| 82 | expect(fetched.name).toEqual(created.name); |
| 83 | expect(fetched.description).toContain("alchemy-id="); |
| 84 | expect(fetched.description).toContain("alchemy-test-dns"); |
| 85 | |
| 86 | const updated = yield* stack.deploy( |
| 87 | Effect.gen(function* () { |
| 88 | return yield* GCP.VMwareEngine.PrivateCloudsManagementDnsZoneBinding("VpcDns", { |
| 89 | privateCloud, |
| 90 | managementDnsZoneBindingId: created.managementDnsZoneBindingId, |
| 91 | vpcNetwork: vpcNetworkOf(project), |
| 92 | description: "alchemy-prod-dns", |
| 93 | }); |
| 94 | }), |
| 95 | ); |
| 96 | |
| 97 | expect(updated.name).toEqual(created.name); |
| 98 | expect(updated.description).toEqual("alchemy-prod-dns"); |
| 99 | |
| 100 | const refetched = |
| 101 | yield* vmwareengine.getProjectsLocationsPrivateCloudsManagementDnsZoneBindings({ |
| 102 | name: created.name, |
| 103 | }); |
| 104 | expect(refetched.description).toContain("alchemy-prod-dns"); |
| 105 | expect(refetched.description).toContain("alchemy-id="); |
| 106 | |
| 107 | yield* stack.destroy(); |
| 108 | |
| 109 | const gone = yield* waitUntilGone(created.name); |
| 110 | expect(gone).toEqual("gone"); |
| 111 | }).pipe(logLevel), |
| 112 | { |
| 113 | tags: ["provider:gcp", "provider:gcp:vmwareengine", "live"], |
| 114 | timeout: 120_000, |
| 115 | }, |
| 116 | ); |