@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.4 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 discoveryengine from "@distilled.cloud/gcp/discoveryengine_v1";
6 import * as Effect from "effect/Effect";
7 import { MinimumLogLevel } from "effect/References";
8 import * as Schedule from "effect/Schedule";
9 import { quotaTolerant } from "./parent.ts";
10
11 const { test } = Test.make({ providers: GCP.providers() });
12
13 const logLevel = Effect.provideService(MinimumLogLevel, process.env.DEBUG ? "Debug" : "Info");
14
15 const runLifecycle = !process.env.FAST;
16
17 const waitUntilGone = (name: string) =>
18 discoveryengine.getProjectsLocationsDataStores({ name }).pipe(
19 Effect.as("found" as const),
20 Effect.catchTag("NotFound", () => Effect.succeed("gone" as const)),
21 Effect.repeat({
22 schedule: Schedule.spaced("2 seconds"),
23 until: (status) => status === "gone",
24 times: 10,
25 }),
26 );
27
28 test.provider(
29 "getProjectsLocationsDataStores on a missing store fails with a typed tag",
30 (stack) =>
31 Effect.gen(function* () {
32 const { project } = yield* GcpEnvironment.current;
33
34 yield* stack.destroy();
35
36 const error = yield* Effect.flip(
37 discoveryengine.getProjectsLocationsDataStores({
38 name: `projects/${project}/locations/global/dataStores/alchemy-ds-missing`,
39 }),
40 );
41 expect(error._tag).toEqual("NotFound");
42
43 yield* stack.destroy();
44 }).pipe(logLevel, quotaTolerant),
45 {
46 tags: ["provider:gcp", "provider:gcp:discoveryengine", "live"],
47 timeout: 90_000,
48 },
49 );
50
51 test.provider.skipIf(!runLifecycle)(
52 "create, update, and delete a data store",
53 (stack) =>
54 Effect.gen(function* () {
55 yield* stack.destroy();
56
57 const created = yield* stack.deploy(
58 Effect.gen(function* () {
59 return yield* GCP.DiscoveryEngine.DataStore("Docs", {
60 location: "global",
61 displayName: "docs",
62 industryVertical: "GENERIC",
63 contentConfig: "NO_CONTENT",
64 solutionTypes: ["SOLUTION_TYPE_SEARCH"],
65 disableCmek: true,
66 });
67 }),
68 );
69
70 expect(created.name).toContain("/dataStores/");
71 expect(created.location).toEqual("global");
72 expect(created.displayName).toEqual("docs");
73 expect(created.industryVertical).toEqual("GENERIC");
74
75 const fetched = yield* discoveryengine.getProjectsLocationsDataStores({
76 name: created.name,
77 });
78 expect(fetched.name).toEqual(created.name);
79 expect(fetched.displayName).toEqual("docs");
80
81 const updated = yield* stack.deploy(
82 Effect.gen(function* () {
83 return yield* GCP.DiscoveryEngine.DataStore("Docs", {
84 dataStoreId: created.dataStoreId,
85 location: "global",
86 displayName: "docs-prod",
87 industryVertical: "GENERIC",
88 contentConfig: "NO_CONTENT",
89 solutionTypes: ["SOLUTION_TYPE_SEARCH"],
90 disableCmek: true,
91 });
92 }),
93 );
94
95 expect(updated.name).toEqual(created.name);
96 expect(updated.displayName).toEqual("docs-prod");
97
98 yield* stack.destroy();
99
100 const gone = yield* waitUntilGone(created.name);
101 expect(gone).toEqual("gone");
102 }).pipe(logLevel, quotaTolerant),
103 {
104 tags: ["provider:gcp", "provider:gcp:discoveryengine", "live"],
105 timeout: 120_000,
106 },
107 );