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 { expect } from "@alchemy.run/test"; |
| 3 | import * as Test from "@alchemy.run/test/Alchemy"; |
| 4 | import * as datastream from "@distilled.cloud/gcp/datastream_v1"; |
| 5 | import * as Effect from "effect/Effect"; |
| 6 | import { LOCATION, logLevel, currentProject, runLifecycle, waitUntilGone } from "./common.ts"; |
| 7 | |
| 8 | const { test } = Test.make({ providers: GCP.providers() }); |
| 9 | |
| 10 | test.provider( |
| 11 | "getProjectsLocationsConnectionProfiles on a missing profile fails with a typed tag", |
| 12 | (stack) => |
| 13 | Effect.gen(function* () { |
| 14 | const project = yield* currentProject; |
| 15 | yield* stack.destroy(); |
| 16 | |
| 17 | const error = yield* Effect.flip( |
| 18 | datastream.getProjectsLocationsConnectionProfiles({ |
| 19 | name: `projects/${project}/locations/${LOCATION}/connectionProfiles/alchemy-missing-profile`, |
| 20 | }), |
| 21 | ); |
| 22 | expect(error._tag).toEqual("NotFound"); |
| 23 | |
| 24 | yield* stack.destroy(); |
| 25 | }).pipe(logLevel), |
| 26 | { |
| 27 | tags: ["provider:gcp", "provider:gcp:datastream", "live"], |
| 28 | timeout: 90_000, |
| 29 | }, |
| 30 | ); |
| 31 | |
| 32 | test.provider.skipIf(!runLifecycle)( |
| 33 | "create, update, and delete a bigquery connection profile", |
| 34 | (stack) => |
| 35 | Effect.gen(function* () { |
| 36 | const project = yield* currentProject; |
| 37 | yield* stack.destroy(); |
| 38 | |
| 39 | const created = yield* stack.deploy( |
| 40 | Effect.gen(function* () { |
| 41 | return yield* GCP.Datastream.ConnectionProfile("BqDest", { |
| 42 | location: LOCATION, |
| 43 | displayName: "bq-dest", |
| 44 | labels: { env: "test" }, |
| 45 | bigqueryProfile: {}, |
| 46 | }); |
| 47 | }), |
| 48 | ); |
| 49 | |
| 50 | expect(created.connectionProfileId).toEqual(expect.any(String)); |
| 51 | expect(created.name).toEqual( |
| 52 | `projects/${project}/locations/${LOCATION}/connectionProfiles/${created.connectionProfileId}`, |
| 53 | ); |
| 54 | expect(created.location).toEqual(LOCATION); |
| 55 | expect(created.displayName).toEqual("bq-dest"); |
| 56 | expect(created.labels).toMatchObject({ env: "test" }); |
| 57 | expect(created.bigqueryProfile).toEqual({}); |
| 58 | |
| 59 | const fetched = yield* datastream.getProjectsLocationsConnectionProfiles({ |
| 60 | name: created.name, |
| 61 | }); |
| 62 | expect(fetched.name).toEqual(created.name); |
| 63 | expect(fetched.displayName).toEqual("bq-dest"); |
| 64 | expect(fetched.labels?.env).toEqual("test"); |
| 65 | |
| 66 | const updated = yield* stack.deploy( |
| 67 | Effect.gen(function* () { |
| 68 | return yield* GCP.Datastream.ConnectionProfile("BqDest", { |
| 69 | connectionProfileId: created.connectionProfileId, |
| 70 | location: LOCATION, |
| 71 | displayName: "bq-dest-v2", |
| 72 | labels: { env: "prod", team: "datastream" }, |
| 73 | bigqueryProfile: {}, |
| 74 | }); |
| 75 | }), |
| 76 | ); |
| 77 | |
| 78 | expect(updated.name).toEqual(created.name); |
| 79 | expect(updated.displayName).toEqual("bq-dest-v2"); |
| 80 | expect(updated.labels).toMatchObject({ env: "prod", team: "datastream" }); |
| 81 | |
| 82 | const fetchedUpdate = yield* datastream.getProjectsLocationsConnectionProfiles({ |
| 83 | name: updated.name, |
| 84 | }); |
| 85 | expect(fetchedUpdate.displayName).toEqual("bq-dest-v2"); |
| 86 | expect(fetchedUpdate.labels?.team).toEqual("datastream"); |
| 87 | |
| 88 | yield* stack.destroy(); |
| 89 | const gone = yield* waitUntilGone( |
| 90 | datastream.getProjectsLocationsConnectionProfiles({ |
| 91 | name: created.name, |
| 92 | }), |
| 93 | ); |
| 94 | expect(gone).toEqual("gone"); |
| 95 | }).pipe(logLevel), |
| 96 | { |
| 97 | tags: ["provider:gcp", "provider:gcp:datastream", "live"], |
| 98 | timeout: 300_000, |
| 99 | }, |
| 100 | ); |