@devries-cameron20 / t3code Mirror · read-only
Fork 0

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

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 06:00 UTC

main
ts 80 lines 2.78 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.getProjectsLocationsLakes({ 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",
27 (stack) =>
28 Effect.gen(function* () {
29 yield* stack.destroy();
30
31 const created = yield* stack.deploy(
32 Effect.gen(function* () {
33 return yield* GCP.Dataplex.Lake("Warehouse", {
34 location: "us-central1",
35 displayName: "lake a",
36 description: "lake a",
37 labels: { env: "test" },
38 });
39 }),
40 );
41
42 expect(created.name).toContain("/lakes/");
43 expect(created.lakeId).toEqual(expect.any(String));
44 expect(created.location).toEqual("us-central1");
45 expect(created.displayName).toEqual("lake a");
46 expect(created.description).toEqual("lake a");
47 expect(created.labels).toMatchObject({ env: "test" });
48
49 const fetched = yield* dataplex.getProjectsLocationsLakes({
50 name: created.name,
51 });
52 expect(fetched.name).toEqual(created.name);
53 expect(fetched.labels?.env).toEqual("test");
54 expect(Object.keys(fetched.labels ?? {}).some((key) => key.startsWith("alchemy-"))).toEqual(
55 true,
56 );
57
58 const updated = yield* stack.deploy(
59 Effect.gen(function* () {
60 return yield* GCP.Dataplex.Lake("Warehouse", {
61 lakeId: created.lakeId,
62 location: "us-central1",
63 displayName: "lake b",
64 description: "lake b",
65 labels: { env: "prod", team: "data" },
66 });
67 }),
68 );
69
70 expect(updated.name).toEqual(created.name);
71 expect(updated.displayName).toEqual("lake b");
72 expect(updated.description).toEqual("lake b");
73 expect(updated.labels).toMatchObject({ env: "prod", team: "data" });
74
75 yield* stack.destroy();
76 const gone = yield* waitUntilGone(created.name);
77 expect(gone).toEqual("gone");
78 }).pipe(logLevel, withDataplexSlot),
79 { tags: ["provider:gcp", "provider:gcp:dataplex", "live"], timeout: 900_000 },
80 );