| 1 | import * as GCP from "@/GCP"; |
| 2 | import * as Test from "@/Test/Alchemy"; |
| 3 | import * as workstations from "@distilled.cloud/gcp/workstations_v1"; |
| 4 | import { expect } from "alchemy-test"; |
| 5 | import * as Effect from "effect/Effect"; |
| 6 | import { MinimumLogLevel } from "effect/References"; |
| 7 | import { GcpEnvironment } from "@/GCP/Environment"; |
| 8 | |
| 9 | const { test } = Test.make({ providers: GCP.providers() }); |
| 10 | |
| 11 | const logLevel = Effect.provideService( |
| 12 | MinimumLogLevel, |
| 13 | process.env.DEBUG ? "Debug" : "Info", |
| 14 | ); |
| 15 | |
| 16 | test.provider( |
| 17 | "getProjectsLocationsWorkstationClustersWorkstationConfigs on a missing config fails with a typed tag", |
| 18 | (stack) => |
| 19 | Effect.gen(function* () { |
| 20 | const { project } = yield* GcpEnvironment.current; |
| 21 | yield* stack.destroy(); |
| 22 | |
| 23 | const error = yield* Effect.flip( |
| 24 | workstations.getProjectsLocationsWorkstationClustersWorkstationConfigs({ |
| 25 | name: `projects/${project}/locations/us-central1/workstationClusters/alchemy-missing-cluster/workstationConfigs/alchemy-missing-config`, |
| 26 | }), |
| 27 | ); |
| 28 | expect(error._tag).toEqual("NotFound"); |
| 29 | |
| 30 | const page = |
| 31 | yield* workstations.listProjectsLocationsWorkstationClustersWorkstationConfigs( |
| 32 | { |
| 33 | parent: `projects/${project}/locations/-/workstationClusters/-`, |
| 34 | pageSize: 10, |
| 35 | }, |
| 36 | ); |
| 37 | expect( |
| 38 | (page.workstationConfigs ?? []).map((item) => item.name), |
| 39 | ).not.toContain( |
| 40 | `projects/${project}/locations/us-central1/workstationClusters/alchemy-missing-cluster/workstationConfigs/alchemy-missing-config`, |
| 41 | ); |
| 42 | |
| 43 | yield* stack.destroy(); |
| 44 | }).pipe(logLevel), |
| 45 | { |
| 46 | tags: ["provider:gcp", "provider:gcp:workstations", "live"], |
| 47 | timeout: 90_000, |
| 48 | }, |
| 49 | ); |
| 50 | |
| 51 | test.provider( |
| 52 | "create against a missing cluster is rejected with a typed tag", |
| 53 | (stack) => |
| 54 | Effect.gen(function* () { |
| 55 | const { project } = yield* GcpEnvironment.current; |
| 56 | yield* stack.destroy(); |
| 57 | |
| 58 | const error = yield* Effect.flip( |
| 59 | stack.deploy( |
| 60 | Effect.gen(function* () { |
| 61 | return yield* GCP.Workstations.WorkstationClustersWorkstationConfig( |
| 62 | "Code", |
| 63 | { |
| 64 | workstationCluster: `projects/${project}/locations/us-central1/workstationClusters/alchemy-missing-cluster`, |
| 65 | displayName: "alchemy-test-config", |
| 66 | labels: { env: "test" }, |
| 67 | }, |
| 68 | ); |
| 69 | }), |
| 70 | ), |
| 71 | ); |
| 72 | expect(error._tag).toEqual("NotFound"); |
| 73 | |
| 74 | yield* stack.destroy(); |
| 75 | }).pipe(logLevel), |
| 76 | { |
| 77 | tags: ["provider:gcp", "provider:gcp:workstations", "live"], |
| 78 | timeout: 90_000, |
| 79 | }, |
| 80 | ); |