The best way to control Claude Code, Codex and more from any computer or phone

main
ts 107 lines 3.87 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 datamigration from "@distilled.cloud/gcp/datamigration_v1";
5 import * as Effect from "effect/Effect";
6 import { logLevel, currentProject, waitUntilGone } from "./common.ts";
7
8 const { test } = Test.make({ providers: GCP.providers() });
9
10 test.provider(
11 "getProjectsLocationsConversionWorkspaces on a missing workspace fails with a typed tag",
12 (stack) =>
13 Effect.gen(function* () {
14 const project = yield* currentProject;
15
16 yield* stack.destroy();
17
18 const error = yield* Effect.flip(
19 datamigration.getProjectsLocationsConversionWorkspaces({
20 name: `projects/${project}/locations/us-central1/conversionWorkspaces/alchemy-missing-workspace`,
21 }),
22 );
23 expect(error._tag).toEqual("NotFound");
24
25 yield* stack.destroy();
26 }).pipe(logLevel),
27 {
28 tags: ["provider:gcp", "provider:gcp:datamigration", "live"],
29 timeout: 90_000,
30 },
31 );
32
33 test.provider(
34 "create, update, and delete a conversion workspace",
35 (stack) =>
36 Effect.gen(function* () {
37 const project = yield* currentProject;
38
39 yield* stack.destroy();
40
41 const created = yield* stack.deploy(
42 Effect.gen(function* () {
43 return yield* GCP.DataMigration.ConversionWorkspace("OracleToPg", {
44 location: "us-central1",
45 displayName: "oracle-to-pg",
46 source: { engine: "ORACLE", version: "11" },
47 destination: { engine: "POSTGRESQL", version: "14" },
48 globalSettings: { skip_triggers: "false" },
49 });
50 }),
51 );
52
53 expect(created.conversionWorkspaceId).toEqual(expect.any(String));
54 expect(created.name).toEqual(
55 `projects/${project}/locations/us-central1/conversionWorkspaces/${created.conversionWorkspaceId}`,
56 );
57 expect(created.location).toEqual("us-central1");
58 expect(created.displayName).toEqual("oracle-to-pg");
59 expect(created.source?.engine).toEqual("ORACLE");
60 expect(created.destination?.engine).toEqual("POSTGRESQL");
61 expect(created.globalSettings).toMatchObject({ skip_triggers: "false" });
62
63 const fetched = yield* datamigration.getProjectsLocationsConversionWorkspaces({
64 name: created.name,
65 });
66 expect(fetched.name).toEqual(created.name);
67 expect(fetched.displayName).toMatch(/^\[(alchemy|alc) /);
68 expect(fetched.displayName).toContain("oracle-to-pg");
69 expect(fetched.source?.engine).toEqual("ORACLE");
70 expect(fetched.destination?.version).toEqual("14");
71
72 const updated = yield* stack.deploy(
73 Effect.gen(function* () {
74 return yield* GCP.DataMigration.ConversionWorkspace("OracleToPg", {
75 conversionWorkspaceId: created.conversionWorkspaceId,
76 location: "us-central1",
77 displayName: "oracle-to-pg-v2",
78 source: { engine: "ORACLE", version: "11" },
79 destination: { engine: "POSTGRESQL", version: "14" },
80 globalSettings: { skip_triggers: "true" },
81 });
82 }),
83 );
84
85 expect(updated.name).toEqual(created.name);
86 expect(updated.displayName).toEqual("oracle-to-pg-v2");
87 expect(updated.globalSettings).toMatchObject({ skip_triggers: "true" });
88
89 const fetchedUpdate = yield* datamigration.getProjectsLocationsConversionWorkspaces({
90 name: updated.name,
91 });
92 expect(fetchedUpdate.displayName).toContain("oracle-to-pg-v2");
93 expect(fetchedUpdate.globalSettings?.skip_triggers).toEqual("true");
94
95 yield* stack.destroy();
96 const gone = yield* waitUntilGone(
97 datamigration.getProjectsLocationsConversionWorkspaces({
98 name: created.name,
99 }),
100 );
101 expect(gone).toEqual("gone");
102 }).pipe(logLevel),
103 {
104 tags: ["provider:gcp", "provider:gcp:datamigration", "live"],
105 timeout: 90_000,
106 },
107 );