@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 121 lines 4.01 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 vmwareengine from "@distilled.cloud/gcp/vmwareengine_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 // Private clouds need VMware Engine node quota and bill thousands of dollars
15 // a month; set GCP_TEST_VMWAREENGINE=1 on an entitled project to opt in.
16 const runLifecycle = !!process.env.GCP_TEST_VMWAREENGINE && !process.env.FAST;
17
18 const waitUntilGone = (name: string) =>
19 vmwareengine.getProjectsLocationsDatastores({ name }).pipe(
20 Effect.as("found" as const),
21 Effect.catchTag("NotFound", () => Effect.succeed("gone" as const)),
22 Effect.repeat({
23 schedule: Schedule.spaced("2 seconds"),
24 until: (status) => status === "gone",
25 times: 10,
26 }),
27 );
28
29 test.provider(
30 "getProjectsLocationsDatastores on a missing datastore fails with a typed tag",
31 (stack) =>
32 Effect.gen(function* () {
33 const { project } = yield* GcpEnvironment.current;
34
35 yield* stack.destroy();
36
37 const error = yield* Effect.flip(
38 vmwareengine.getProjectsLocationsDatastores({
39 name: `projects/${project}/locations/us-central1/datastores/alchemy-ds-missing`,
40 }),
41 );
42 expect(error._tag).toEqual("NotFound");
43
44 yield* stack.destroy();
45 }).pipe(logLevel),
46 {
47 tags: ["provider:gcp", "provider:gcp:vmwareengine", "live"],
48 timeout: 90_000,
49 },
50 );
51
52 test.provider.skipIf(!runLifecycle)(
53 "create, update, and delete a datastore",
54 (stack) =>
55 Effect.gen(function* () {
56 const { project } = yield* GcpEnvironment.current;
57
58 yield* stack.destroy();
59
60 const created = yield* stack.deploy(
61 Effect.gen(function* () {
62 return yield* GCP.VMwareEngine.Datastore("Nfs", {
63 nfsDatastore: {
64 thirdPartyFileService: {
65 servers: ["10.0.0.8"],
66 network: `projects/${project}/global/networks/default`,
67 fileShare: "vol1",
68 },
69 },
70 description: "alchemy-test-ds",
71 });
72 }),
73 );
74
75 expect(created.name).toContain("/datastores/");
76 expect(created.datastoreId).toEqual(expect.any(String));
77 expect(created.location).toEqual("us-central1");
78 expect(created.description).toEqual("alchemy-test-ds");
79
80 const fetched = yield* vmwareengine.getProjectsLocationsDatastores({
81 name: created.name,
82 });
83 expect(fetched.name).toEqual(created.name);
84 expect(fetched.description).toContain("alchemy-id=");
85 expect(fetched.description).toContain("alchemy-test-ds");
86
87 const updated = yield* stack.deploy(
88 Effect.gen(function* () {
89 return yield* GCP.VMwareEngine.Datastore("Nfs", {
90 datastoreId: created.datastoreId,
91 nfsDatastore: created.nfsDatastore ?? {
92 thirdPartyFileService: {
93 servers: ["10.0.0.8"],
94 network: `projects/${project}/global/networks/default`,
95 fileShare: "vol1",
96 },
97 },
98 description: "alchemy-prod-ds",
99 });
100 }),
101 );
102
103 expect(updated.name).toEqual(created.name);
104 expect(updated.description).toEqual("alchemy-prod-ds");
105
106 const refetched = yield* vmwareengine.getProjectsLocationsDatastores({
107 name: created.name,
108 });
109 expect(refetched.description).toContain("alchemy-prod-ds");
110 expect(refetched.description).toContain("alchemy-id=");
111
112 yield* stack.destroy();
113
114 const gone = yield* waitUntilGone(created.name);
115 expect(gone).toEqual("gone");
116 }).pipe(logLevel),
117 {
118 tags: ["provider:gcp", "provider:gcp:vmwareengine", "live"],
119 timeout: 120_000,
120 },
121 );