The best way to control Claude Code, Codex and more from any computer or phone
| 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 gkebackup from "@distilled.cloud/gcp/gkebackup_v1"; |
| 6 | import * as Effect from "effect/Effect"; |
| 7 | import { MinimumLogLevel } from "effect/References"; |
| 8 | |
| 9 | const { test } = Test.make({ providers: GCP.providers() }); |
| 10 | |
| 11 | const logLevel = Effect.provideService(MinimumLogLevel, process.env.DEBUG ? "Debug" : "Info"); |
| 12 | |
| 13 | test.provider( |
| 14 | "getProjectsLocationsRestorePlans on a missing plan fails with a typed tag", |
| 15 | (stack) => |
| 16 | Effect.gen(function* () { |
| 17 | const { project } = yield* GcpEnvironment.current; |
| 18 | |
| 19 | yield* stack.destroy(); |
| 20 | |
| 21 | const error = yield* Effect.flip( |
| 22 | gkebackup.getProjectsLocationsRestorePlans({ |
| 23 | name: `projects/${project}/locations/us-central1/restorePlans/alchemy-missing-plan`, |
| 24 | }), |
| 25 | ); |
| 26 | expect(error._tag).toEqual("NotFound"); |
| 27 | |
| 28 | const page = yield* gkebackup.listProjectsLocationsRestorePlans({ |
| 29 | parent: `projects/${project}/locations/-`, |
| 30 | pageSize: 10, |
| 31 | }); |
| 32 | expect((page.restorePlans ?? []).map((item) => item.name)).not.toContain( |
| 33 | `projects/${project}/locations/us-central1/restorePlans/alchemy-missing-plan`, |
| 34 | ); |
| 35 | |
| 36 | yield* stack.destroy(); |
| 37 | }).pipe(logLevel), |
| 38 | { tags: ["provider:gcp", "provider:gcp:gkebackup", "live"], timeout: 90_000 }, |
| 39 | ); |
| 40 | |
| 41 | test.provider( |
| 42 | "create against a missing backup plan is rejected with a typed tag", |
| 43 | (stack) => |
| 44 | Effect.gen(function* () { |
| 45 | const { project } = yield* GcpEnvironment.current; |
| 46 | |
| 47 | yield* stack.destroy(); |
| 48 | |
| 49 | const error = yield* Effect.flip( |
| 50 | stack.deploy( |
| 51 | Effect.gen(function* () { |
| 52 | return yield* GCP.GKEBackup.RestorePlan("Rollback", { |
| 53 | cluster: `projects/${project}/locations/us-central1/clusters/alchemy-gkebackup-missing`, |
| 54 | backupPlan: `projects/${project}/locations/us-central1/backupPlans/alchemy-missing-plan`, |
| 55 | restoreConfig: { |
| 56 | allNamespaces: true, |
| 57 | namespacedResourceRestoreMode: "FAIL_ON_CONFLICT", |
| 58 | volumeDataRestorePolicy: "NO_VOLUME_DATA_RESTORATION", |
| 59 | }, |
| 60 | description: "alchemy-test-plan", |
| 61 | labels: { env: "test" }, |
| 62 | }); |
| 63 | }), |
| 64 | ), |
| 65 | ); |
| 66 | expect(error._tag).toEqual("NotFound"); |
| 67 | |
| 68 | yield* stack.destroy(); |
| 69 | }).pipe(logLevel), |
| 70 | { tags: ["provider:gcp", "provider:gcp:gkebackup", "live"], timeout: 90_000 }, |
| 71 | ); |