@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 82 lines 2.7 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 dlp from "@distilled.cloud/gcp/dlp_v2";
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 runLifecycle = !process.env.FAST;
15
16 const waitUntilGone = (name: string) =>
17 dlp.getProjectsDlpJobs({ name }).pipe(
18 Effect.as("found" as const),
19 Effect.catchTag("NotFound", () => Effect.succeed("gone" as const)),
20 Effect.repeat({
21 schedule: Schedule.spaced("1 second"),
22 until: (status) => status === "gone",
23 times: 10,
24 }),
25 );
26
27 test.provider(
28 "getProjectsDlpJobs on a missing job fails with a typed tag",
29 (stack) =>
30 Effect.gen(function* () {
31 const { project } = yield* GcpEnvironment.current;
32 yield* stack.destroy();
33
34 const error = yield* Effect.flip(
35 dlp.getProjectsDlpJobs({
36 name: `projects/${project}/dlpJobs/i-alchemy-missing`,
37 }),
38 );
39 expect(error._tag).toEqual("NotFound");
40
41 yield* stack.destroy();
42 }).pipe(logLevel),
43 { tags: ["provider:gcp", "provider:gcp:dlp", "live"], timeout: 90_000 },
44 );
45
46 test.provider.skipIf(!runLifecycle)(
47 "create and delete a hybrid inspect job",
48 (stack) =>
49 Effect.gen(function* () {
50 const { project } = yield* GcpEnvironment.current;
51 yield* stack.destroy();
52
53 const created = yield* stack.deploy(
54 Effect.gen(function* () {
55 return yield* GCP.DLP.DlpJob("Scan", {
56 inspectJob: {
57 inspectConfig: { infoTypes: [{ name: "EMAIL_ADDRESS" }] },
58 storageConfig: {
59 hybridOptions: { description: "hybrid scan" },
60 },
61 },
62 });
63 }),
64 );
65
66 expect(created.jobId).toEqual(expect.any(String));
67 expect(created.name).toEqual(`projects/${project}/dlpJobs/${created.jobId}`);
68 expect(created.project).toEqual(project);
69 expect(created.type).toEqual("INSPECT_JOB");
70 expect(created.state).toEqual(expect.any(String));
71
72 const fetched = yield* dlp.getProjectsDlpJobs({ name: created.name });
73 expect(fetched.name).toEqual(created.name);
74 expect(fetched.type).toEqual("INSPECT_JOB");
75
76 yield* stack.destroy();
77
78 const gone = yield* waitUntilGone(created.name);
79 expect(gone).toEqual("gone");
80 }).pipe(logLevel),
81 { tags: ["provider:gcp", "provider:gcp:dlp", "live"], timeout: 90_000 },
82 );