| 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 | "getProjectsLocationsServicesBackups on a missing backup 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.getProjectsLocationsServicesBackups({ |
| 25 | name: `projects/${project}/locations/us-central1/services/alchemy-missing-service/backups/alchemy-missing-backup`, |
| 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 against a missing service is rejected with a typed tag", |
| 37 | (stack) => |
| 38 | Effect.gen(function* () { |
| 39 | const { project } = yield* GcpEnvironment.current; |
| 40 | yield* stack.destroy(); |
| 41 | |
| 42 | const error = yield* Effect.flip( |
| 43 | stack.deploy( |
| 44 | Effect.gen(function* () { |
| 45 | return yield* GCP.Metastore.ServicesBackup("Nightly", { |
| 46 | service: `projects/${project}/locations/us-central1/services/alchemy-missing-service`, |
| 47 | description: "alchemy-test-backup", |
| 48 | }); |
| 49 | }), |
| 50 | ), |
| 51 | ); |
| 52 | expect(error._tag).toEqual("ServiceDisabled"); |
| 53 | |
| 54 | yield* stack.destroy(); |
| 55 | }).pipe(logLevel), |
| 56 | { tags: ["provider:gcp", "provider:gcp:metastore", "live"], timeout: 90_000 }, |
| 57 | ); |