| 1 | import * as GCP from "@/GCP"; |
| 2 | import * as Test from "@/Test/Alchemy"; |
| 3 | import * as metastore from "@distilled.cloud/gcp/metastore_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 | "getProjectsLocationsServices on a missing service 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 | metastore.getProjectsLocationsServices({ |
| 25 | name: `projects/${project}/locations/us-central1/services/alchemy-missing-service`, |
| 26 | }), |
| 27 | ); |
| 28 | expect(error._tag).toEqual("ServiceDisabled"); |
| 29 | |
| 30 | yield* stack.destroy(); |
| 31 | }).pipe(logLevel), |
| 32 | { tags: ["provider:gcp", "provider:gcp:metastore", "live"], timeout: 90_000 }, |
| 33 | ); |
| 34 | |
| 35 | test.provider( |
| 36 | "create is rejected when the Dataproc Metastore API is disabled", |
| 37 | (stack) => |
| 38 | Effect.gen(function* () { |
| 39 | yield* stack.destroy(); |
| 40 | |
| 41 | const error = yield* Effect.flip( |
| 42 | stack.deploy( |
| 43 | Effect.gen(function* () { |
| 44 | return yield* GCP.Metastore.Service("Hive", { |
| 45 | location: "us-central1", |
| 46 | hiveMetastoreConfig: { version: "3.1.2" }, |
| 47 | tier: "DEVELOPER", |
| 48 | labels: { env: "test" }, |
| 49 | }); |
| 50 | }), |
| 51 | ), |
| 52 | ); |
| 53 | expect(error._tag).toEqual("ServiceDisabled"); |
| 54 | |
| 55 | yield* stack.destroy(); |
| 56 | }).pipe(logLevel), |
| 57 | { tags: ["provider:gcp", "provider:gcp:metastore", "live"], timeout: 90_000 }, |
| 58 | ); |