@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.89 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 storagetransfer from "@distilled.cloud/gcp/storagetransfer_v1";
5 import * as Effect from "effect/Effect";
6 import { MinimumLogLevel } from "effect/References";
7 import * as Schedule from "effect/Schedule";
8
9 const { test } = Test.make({ providers: GCP.providers() });
10
11 const logLevel = Effect.provideService(MinimumLogLevel, process.env.DEBUG ? "Debug" : "Info");
12
13 const waitUntilGone = (name: string) =>
14 storagetransfer.getProjectsAgentPools({ name }).pipe(
15 Effect.as("found" as const),
16 Effect.catchTag("NotFound", () => Effect.succeed("gone" as const)),
17 Effect.repeat({
18 schedule: Schedule.spaced("1 second"),
19 until: (status) => status === "gone",
20 times: 10,
21 }),
22 );
23
24 test.provider(
25 "create, update, and delete an agent pool",
26 (stack) =>
27 Effect.gen(function* () {
28 yield* stack.destroy();
29
30 const created = yield* stack.deploy(
31 Effect.gen(function* () {
32 return yield* GCP.StorageTransfer.AgentPool("OnPrem", {
33 displayName: "warehouse scanners",
34 });
35 }),
36 );
37
38 expect(created.agentPoolId).toEqual(expect.any(String));
39 expect(created.name).toEqual(`projects/${created.project}/agentPools/${created.agentPoolId}`);
40 expect(created.displayName).toEqual("warehouse scanners");
41 expect(created.state).toEqual("CREATED");
42 expect(created.bandwidthLimit).toBeUndefined();
43
44 const fetched = yield* storagetransfer.getProjectsAgentPools({
45 name: created.name,
46 });
47 expect(fetched.name).toEqual(created.name);
48 expect(fetched.displayName).toContain("alchemy-id=");
49 expect(fetched.displayName).toContain("warehouse scanners");
50 expect(fetched.state).toEqual("CREATED");
51
52 const updated = yield* stack.deploy(
53 Effect.gen(function* () {
54 return yield* GCP.StorageTransfer.AgentPool("OnPrem", {
55 agentPoolId: created.agentPoolId,
56 displayName: "warehouse scanners v2",
57 bandwidthLimit: { limitMbps: "120" },
58 });
59 }),
60 );
61
62 expect(updated.name).toEqual(created.name);
63 expect(updated.agentPoolId).toEqual(created.agentPoolId);
64 expect(updated.displayName).toEqual("warehouse scanners v2");
65 expect(updated.bandwidthLimit).toEqual({ limitMbps: "120" });
66
67 const fetchedUpdate = yield* storagetransfer.getProjectsAgentPools({
68 name: created.name,
69 });
70 expect(fetchedUpdate.displayName).toContain("warehouse scanners v2");
71 expect(fetchedUpdate.bandwidthLimit?.limitMbps).toEqual("120");
72
73 yield* stack.destroy();
74
75 const gone = yield* waitUntilGone(created.name);
76 expect(gone).toEqual("gone");
77 }).pipe(logLevel),
78 {
79 tags: ["provider:gcp", "provider:gcp:storagetransfer", "live"],
80 timeout: 90_000,
81 },
82 );