@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 107 lines 3.58 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 datalineage from "@distilled.cloud/gcp/datalineage_v1";
6 import * as Effect from "effect/Effect";
7 import { MinimumLogLevel } from "effect/References";
8 import * as Schedule from "effect/Schedule";
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 datalineage.getProjectsLocationsProcesses({ name }).pipe(
16 Effect.as("found" as const),
17 Effect.catchTag("NotFound", () => Effect.succeed("gone" as const)),
18 Effect.repeat({
19 schedule: Schedule.spaced("1 second"),
20 until: (status) => status === "gone",
21 times: 10,
22 }),
23 );
24
25 test.provider(
26 "getProjectsLocationsProcesses on a missing process fails with a typed tag",
27 (stack) =>
28 Effect.gen(function* () {
29 const { project } = yield* GcpEnvironment.current;
30
31 yield* stack.destroy();
32
33 const error = yield* Effect.flip(
34 datalineage.getProjectsLocationsProcesses({
35 name: `projects/${project}/locations/us-central1/processes/alchemy-missing-process`,
36 }),
37 );
38 expect(error._tag).toEqual("NotFound");
39
40 yield* stack.destroy();
41 }).pipe(logLevel),
42 {
43 tags: ["provider:gcp", "provider:gcp:datalineage", "live"],
44 timeout: 90_000,
45 },
46 );
47
48 test.provider.skipIf(!!process.env.FAST)(
49 "create, update, and delete a lineage process",
50 (stack) =>
51 Effect.gen(function* () {
52 yield* stack.destroy();
53
54 const created = yield* stack.deploy(
55 Effect.gen(function* () {
56 return yield* GCP.DataLineage.Process("Etl", {
57 location: "us-central1",
58 displayName: "etl a",
59 origin: { sourceType: "CUSTOM", name: "alchemy" },
60 attributes: { env: "test" },
61 });
62 }),
63 );
64
65 expect(created.name).toContain("/processes/");
66 expect(created.processId).toEqual(expect.any(String));
67 expect(created.location).toEqual("us-central1");
68 expect(created.displayName).toEqual("etl a");
69 expect(created.origin?.sourceType).toEqual("CUSTOM");
70 expect(created.attributes).toMatchObject({ env: "test" });
71
72 const fetched = yield* datalineage.getProjectsLocationsProcesses({
73 name: created.name,
74 });
75 expect(fetched.name).toEqual(created.name);
76 expect(fetched.displayName).toEqual("etl a");
77 expect(fetched.attributes?.env).toEqual("test");
78 expect(
79 Object.keys(fetched.attributes ?? {}).some((key) => key.startsWith("alchemy-")),
80 ).toEqual(true);
81
82 const updated = yield* stack.deploy(
83 Effect.gen(function* () {
84 return yield* GCP.DataLineage.Process("Etl", {
85 processId: created.processId,
86 location: "us-central1",
87 displayName: "etl b",
88 origin: { sourceType: "CUSTOM", name: "dbt" },
89 attributes: { env: "prod", team: "data" },
90 });
91 }),
92 );
93
94 expect(updated.name).toEqual(created.name);
95 expect(updated.displayName).toEqual("etl b");
96 expect(updated.origin?.name).toEqual("dbt");
97 expect(updated.attributes).toMatchObject({ env: "prod", team: "data" });
98
99 yield* stack.destroy();
100 const gone = yield* waitUntilGone(created.name);
101 expect(gone).toEqual("gone");
102 }).pipe(logLevel),
103 {
104 tags: ["provider:gcp", "provider:gcp:datalineage", "live"],
105 timeout: 90_000,
106 },
107 );