@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 111 lines 3.76 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 vmmigration from "@distilled.cloud/gcp/vmmigration_v1";
5 import * as Effect from "effect/Effect";
6 import { dummyAws, logLevel, currentProject, runSourceLifecycle, waitUntilGone } from "./common.ts";
7
8 const { test } = Test.make({ providers: GCP.providers() });
9
10 test.provider(
11 "getProjectsLocationsSourcesMigratingVms on a missing vm fails with a typed tag",
12 (stack) =>
13 Effect.gen(function* () {
14 const project = yield* currentProject;
15 yield* stack.destroy();
16
17 const error = yield* Effect.flip(
18 vmmigration.getProjectsLocationsSourcesMigratingVms({
19 name: `projects/${project}/locations/us-central1/sources/alchemy-missing-source/migratingVms/alchemy-missing-vm`,
20 }),
21 );
22 expect(error._tag).toEqual("NotFound");
23
24 yield* stack.destroy();
25 }).pipe(logLevel),
26 {
27 tags: ["provider:gcp", "provider:gcp:vmmigration", "live"],
28 timeout: 90_000,
29 },
30 );
31
32 test.provider.skipIf(!runSourceLifecycle)(
33 "create, update, and delete a vm migration migrating vm",
34 (stack) =>
35 Effect.gen(function* () {
36 yield* stack.destroy();
37
38 const created = yield* stack.deploy(
39 Effect.gen(function* () {
40 const source = yield* GCP.VMMigration.Source("VmSource", {
41 aws: dummyAws,
42 });
43 const target = yield* GCP.VMMigration.Target("VmLanding");
44 return yield* GCP.VMMigration.SourcesMigratingVm("Web", {
45 source: source.name,
46 sourceVmId: "i-0123456789abcdef0",
47 displayName: "web-1",
48 description: "web tier",
49 labels: { env: "test" },
50 computeEngineTargetDefaults: {
51 vmName: "web-1",
52 machineType: "n2-standard-2",
53 zone: "us-central1-a",
54 targetProject: target.name,
55 },
56 });
57 }),
58 );
59
60 expect(created.migratingVmId).toEqual(expect.any(String));
61 expect(created.name).toContain("/migratingVms/");
62 expect(created.sourceVmId).toEqual("i-0123456789abcdef0");
63 expect(created.displayName).toEqual("web-1");
64 expect(created.labels).toMatchObject({ env: "test" });
65
66 const fetched = yield* vmmigration.getProjectsLocationsSourcesMigratingVms({
67 name: created.name,
68 });
69 expect(fetched.name).toEqual(created.name);
70 expect(fetched.labels?.env).toEqual("test");
71
72 const updated = yield* stack.deploy(
73 Effect.gen(function* () {
74 const source = yield* GCP.VMMigration.Source("VmSource", {
75 aws: dummyAws,
76 });
77 const target = yield* GCP.VMMigration.Target("VmLanding");
78 return yield* GCP.VMMigration.SourcesMigratingVm("Web", {
79 source: source.name,
80 migratingVmId: created.migratingVmId,
81 sourceVmId: "i-0123456789abcdef0",
82 displayName: "web-1-v2",
83 description: "web tier v2",
84 labels: { env: "prod" },
85 computeEngineTargetDefaults: {
86 vmName: "web-1",
87 machineType: "n2-standard-4",
88 zone: "us-central1-a",
89 targetProject: target.name,
90 },
91 });
92 }),
93 );
94
95 expect(updated.name).toEqual(created.name);
96 expect(updated.displayName).toEqual("web-1-v2");
97 expect(updated.labels).toMatchObject({ env: "prod" });
98
99 yield* stack.destroy();
100 const gone = yield* waitUntilGone(
101 vmmigration.getProjectsLocationsSourcesMigratingVms({
102 name: created.name,
103 }),
104 );
105 expect(gone).toEqual("gone");
106 }).pipe(logLevel),
107 {
108 tags: ["provider:gcp", "provider:gcp:vmmigration", "live"],
109 timeout: 120_000,
110 },
111 );