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

main
ts 97 lines 3.56 KB
Raw
1 import * as GCP from "@alchemy.run/gcp";
2 import { expect } from "@alchemy.run/test";
3 import * as Test from "@alchemy.run/test/Alchemy";
4 import * as dataplex from "@distilled.cloud/gcp/dataplex_v1";
5 import * as Effect from "effect/Effect";
6 import { MinimumLogLevel } from "effect/References";
7 import * as Schedule from "effect/Schedule";
8 import { withDataplexSlot } from "./quota.ts";
9
10 const { test } = Test.make({ providers: GCP.providers() });
11
12 const logLevel = Effect.provideService(MinimumLogLevel, process.env.DEBUG ? "Debug" : "Info");
13
14 const waitUntilGone = (name: string) =>
15 dataplex.getProjectsLocationsLakesZones({ name }).pipe(
16 Effect.as("found" as const),
17 Effect.catchTag("NotFound", () => Effect.succeed("gone" as const)),
18 Effect.repeat({
19 schedule: Schedule.spaced("2 seconds"),
20 until: (status) => status === "gone",
21 times: 10,
22 }),
23 );
24
25 test.provider.skipIf(!!process.env.FAST)(
26 "create, update, and delete a lake zone",
27 (stack) =>
28 Effect.gen(function* () {
29 yield* stack.destroy();
30
31 const created = yield* stack.deploy(
32 Effect.gen(function* () {
33 const lake = yield* GCP.Dataplex.Lake("Warehouse", {
34 location: "us-central1",
35 labels: { env: "test" },
36 });
37 const zone = yield* GCP.Dataplex.LakesZone("Landing", {
38 lake: lake.name,
39 type: "RAW",
40 locationType: "SINGLE_REGION",
41 displayName: "landing a",
42 description: "raw landing",
43 labels: { env: "test" },
44 discoverySpec: { enabled: false },
45 });
46 return { lake, zone };
47 }),
48 );
49
50 expect(created.zone.name).toContain("/zones/");
51 expect(created.zone.zoneId).toEqual(expect.any(String));
52 expect(created.zone.lake).toEqual(created.lake.name);
53 expect(created.zone.type).toEqual("RAW");
54 expect(created.zone.locationType).toEqual("SINGLE_REGION");
55 expect(created.zone.displayName).toEqual("landing a");
56 expect(created.zone.labels).toMatchObject({ env: "test" });
57 expect(created.zone.discoveryEnabled).toEqual(false);
58
59 const fetched = yield* dataplex.getProjectsLocationsLakesZones({
60 name: created.zone.name,
61 });
62 expect(fetched.name).toEqual(created.zone.name);
63 expect(fetched.labels?.env).toEqual("test");
64 expect(fetched.type).toEqual("RAW");
65
66 const updated = yield* stack.deploy(
67 Effect.gen(function* () {
68 const lake = yield* GCP.Dataplex.Lake("Warehouse", {
69 lakeId: created.lake.lakeId,
70 location: "us-central1",
71 labels: { env: "test" },
72 });
73 const zone = yield* GCP.Dataplex.LakesZone("Landing", {
74 lake: lake.name,
75 zoneId: created.zone.zoneId,
76 type: "RAW",
77 locationType: "SINGLE_REGION",
78 displayName: "landing b",
79 description: "raw landing b",
80 labels: { env: "prod", team: "data" },
81 discoverySpec: { enabled: false },
82 });
83 return { lake, zone };
84 }),
85 );
86
87 expect(updated.zone.name).toEqual(created.zone.name);
88 expect(updated.zone.displayName).toEqual("landing b");
89 expect(updated.zone.description).toEqual("raw landing b");
90 expect(updated.zone.labels).toMatchObject({ env: "prod", team: "data" });
91
92 yield* stack.destroy();
93 const gone = yield* waitUntilGone(created.zone.name);
94 expect(gone).toEqual("gone");
95 }).pipe(logLevel, withDataplexSlot),
96 { tags: ["provider:gcp", "provider:gcp:dataplex", "live"], timeout: 900_000 },
97 );