@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 101 lines 3.66 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 migrationcenter from "@distilled.cloud/gcp/migrationcenter_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 const waitUntilGone = (name: string) =>
15 migrationcenter.getProjectsLocationsSources({ name }).pipe(
16 Effect.as("found" as const),
17 Effect.catchTag("NotFound", () => Effect.succeed("gone" as const)),
18 Effect.repeat({
19 schedule: Schedule.spaced("1 second"),
20 until: (status) => status === "gone",
21 times: 10,
22 }),
23 );
24
25 test.provider(
26 "create, update, and delete a migration center source",
27 (stack) =>
28 Effect.gen(function* () {
29 const { project } = yield* GcpEnvironment.current;
30 yield* stack.destroy();
31
32 const created = yield* stack.deploy(
33 Effect.gen(function* () {
34 return yield* GCP.MigrationCenter.Source("Assets", {
35 location: "us-central1",
36 type: "SOURCE_TYPE_CUSTOM",
37 displayName: "custom assets",
38 description: "inventory feed",
39 priority: 1,
40 });
41 }),
42 );
43
44 expect(created.sourceId).toEqual(expect.any(String));
45 expect(created.name).toEqual(
46 `projects/${project}/locations/us-central1/sources/${created.sourceId}`,
47 );
48 expect(created.project).toEqual(project);
49 expect(created.location).toEqual("us-central1");
50 expect(created.type).toEqual("SOURCE_TYPE_CUSTOM");
51 expect(created.managed ?? false).toEqual(false);
52 expect(created.displayName).toEqual("custom assets");
53 expect(created.description).toEqual("inventory feed");
54 expect(created.priority).toEqual(1);
55
56 const fetched = yield* migrationcenter.getProjectsLocationsSources({
57 name: created.name,
58 });
59 expect(fetched.name).toEqual(created.name);
60 expect(fetched.type).toEqual("SOURCE_TYPE_CUSTOM");
61 expect(fetched.displayName).toEqual("custom assets");
62 expect(fetched.priority).toEqual(1);
63 expect(fetched.description).toContain("alchemy-id=");
64 expect(fetched.description).toContain("inventory feed");
65
66 const updated = yield* stack.deploy(
67 Effect.gen(function* () {
68 return yield* GCP.MigrationCenter.Source("Assets", {
69 sourceId: created.sourceId,
70 location: "us-central1",
71 type: "SOURCE_TYPE_CUSTOM",
72 displayName: "custom assets v2",
73 description: "inventory feed v2",
74 priority: 10,
75 });
76 }),
77 );
78
79 expect(updated.name).toEqual(created.name);
80 expect(updated.sourceId).toEqual(created.sourceId);
81 expect(updated.displayName).toEqual("custom assets v2");
82 expect(updated.description).toEqual("inventory feed v2");
83 expect(updated.priority).toEqual(10);
84
85 const fetchedUpdate = yield* migrationcenter.getProjectsLocationsSources({
86 name: created.name,
87 });
88 expect(fetchedUpdate.displayName).toEqual("custom assets v2");
89 expect(fetchedUpdate.priority).toEqual(10);
90 expect(fetchedUpdate.description).toContain("inventory feed v2");
91
92 yield* stack.destroy();
93
94 const gone = yield* waitUntilGone(created.name);
95 expect(gone).toEqual("gone");
96 }).pipe(logLevel),
97 {
98 tags: ["provider:gcp", "provider:gcp:migrationcenter", "live"],
99 timeout: 180_000,
100 },
101 );