@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 105 lines 3.63 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 containeranalysis from "@distilled.cloud/gcp/containeranalysis_v1";
5 import * as Effect from "effect/Effect";
6 import * as Schedule from "effect/Schedule";
7 import { logLevel, currentProject } from "./common.ts";
8
9 const { test } = Test.make({ providers: GCP.providers() });
10
11 const waitUntilGone = (name: string) =>
12 containeranalysis.getProjectsNotes({ name }).pipe(
13 Effect.as("found" as const),
14 Effect.catchTag("NotFound", () => Effect.succeed("gone" as const)),
15 Effect.repeat({
16 schedule: Schedule.spaced("1 second"),
17 until: (status) => status === "gone",
18 times: 10,
19 }),
20 );
21
22 test.provider(
23 "getProjectsNotes on a missing note fails with a typed tag",
24 (stack) =>
25 Effect.gen(function* () {
26 const project = yield* currentProject;
27 yield* stack.destroy();
28
29 const error = yield* Effect.flip(
30 containeranalysis.getProjectsNotes({
31 name: `projects/${project}/notes/alchemy-missing-note`,
32 }),
33 );
34 expect(error._tag).toEqual("NotFound");
35
36 yield* stack.destroy();
37 }).pipe(logLevel),
38 {
39 tags: ["provider:gcp", "provider:gcp:containeranalysis", "live"],
40 timeout: 90_000,
41 },
42 );
43
44 test.provider(
45 "create, update, and delete a note",
46 (stack) =>
47 Effect.gen(function* () {
48 yield* stack.destroy();
49
50 const created = yield* stack.deploy(
51 Effect.gen(function* () {
52 return yield* GCP.ContainerAnalysis.Note("Authority", {
53 shortDescription: "alchemy test attestor",
54 longDescription: "initial",
55 relatedUrl: [{ url: "https://example.com/policy", label: "policy" }],
56 attestation: { hint: { humanReadableName: "Alchemy QA" } },
57 });
58 }),
59 );
60
61 expect(created.name).toContain("/notes/");
62 expect(created.noteId).toEqual(expect.any(String));
63 expect(created.shortDescription).toEqual("alchemy test attestor");
64 expect(created.longDescription).toEqual("initial");
65 expect(created.kind).toEqual("ATTESTATION");
66 expect(created.attestation?.hint?.humanReadableName).toEqual("Alchemy QA");
67
68 const fetched = yield* containeranalysis.getProjectsNotes({
69 name: created.name,
70 });
71 expect(fetched.name).toEqual(created.name);
72 expect(fetched.shortDescription).toEqual("alchemy test attestor");
73 expect(fetched.longDescription).toContain("[alchemy ");
74 expect(fetched.longDescription).toContain("initial");
75 expect(fetched.kind).toEqual("ATTESTATION");
76
77 const updated = yield* stack.deploy(
78 Effect.gen(function* () {
79 return yield* GCP.ContainerAnalysis.Note("Authority", {
80 noteId: created.noteId,
81 shortDescription: "alchemy test attestor v2",
82 longDescription: "updated",
83 relatedUrl: [
84 { url: "https://example.com/policy", label: "policy" },
85 { url: "https://example.com/docs", label: "docs" },
86 ],
87 attestation: { hint: { humanReadableName: "Alchemy QA" } },
88 });
89 }),
90 );
91
92 expect(updated.name).toEqual(created.name);
93 expect(updated.shortDescription).toEqual("alchemy test attestor v2");
94 expect(updated.longDescription).toEqual("updated");
95 expect(updated.relatedUrl.length).toBeGreaterThanOrEqual(1);
96
97 yield* stack.destroy();
98 const gone = yield* waitUntilGone(created.name);
99 expect(gone).toEqual("gone");
100 }).pipe(logLevel),
101 {
102 tags: ["provider:gcp", "provider:gcp:containeranalysis", "live"],
103 timeout: 90_000,
104 },
105 );