The best way to control Claude Code, Codex and more from any computer or phone

main
ts 66 lines 2.29 KB
Raw
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 "getProjectsLocationsBackupChannels on a missing channel 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.getProjectsLocationsBackupChannels({
23 name: `projects/${project}/locations/us-central1/backupChannels/alchemy-missing-channel`,
24 }),
25 );
26 expect(error._tag).toEqual("NotFound");
27
28 const page = yield* gkebackup.listProjectsLocationsBackupChannels({
29 parent: `projects/${project}/locations/-`,
30 pageSize: 10,
31 });
32 expect((page.backupChannels ?? []).map((item) => item.name)).not.toContain(
33 `projects/${project}/locations/us-central1/backupChannels/alchemy-missing-channel`,
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 with same-project destination is rejected with BadRequest",
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.BackupChannel("Channel", {
53 destinationProject: `projects/${project}`,
54 description: "alchemy-test-channel",
55 labels: { env: "test" },
56 });
57 }),
58 ),
59 );
60 expect(error._tag).toEqual("BadRequest");
61 expect(error.message).toContain("source and destination project cannot be same");
62
63 yield* stack.destroy();
64 }).pipe(logLevel),
65 { tags: ["provider:gcp", "provider:gcp:gkebackup", "live"], timeout: 90_000 },
66 );