@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 88 lines 3.13 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 { logLevel, currentProject, waitUntilGone } from "./common.ts";
7
8 const { test } = Test.make({ providers: GCP.providers() });
9
10 test.provider(
11 "getProjectsLocationsImageImports on a missing import 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.getProjectsLocationsImageImports({
19 name: `projects/${project}/locations/us-central1/imageImports/alchemy-missing-import`,
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 // An image import validates its source object up front (NotFound: Resource
33 // "gs://.../disk.vmdk" was not found), and a project holds a single target
34 // project. Set GCP_TEST_VMMIGRATION_IMAGE_URI to a gs:// VMDK to run it.
35 const imageUri = process.env.GCP_TEST_VMMIGRATION_IMAGE_URI;
36
37 test.provider.skipIf(!imageUri)(
38 "create, update, and delete a vm migration image import",
39 (stack) =>
40 Effect.gen(function* () {
41 const project = yield* currentProject;
42 yield* stack.destroy();
43
44 const created = yield* stack.deploy(
45 Effect.gen(function* () {
46 const target = yield* GCP.VMMigration.Target("ImportLanding");
47 return yield* GCP.VMMigration.ImageImport("Disk", {
48 location: "us-central1",
49 cloudStorageUri: imageUri!,
50 diskImageTargetDefaults: {
51 imageName: "alchemy-imported-disk",
52 targetProject: target.name,
53 description: "imported disk",
54 labels: { env: "test" },
55 },
56 });
57 }),
58 );
59
60 expect(created.imageImportId).toEqual(expect.any(String));
61 expect(created.name).toEqual(
62 `projects/${project}/locations/us-central1/imageImports/${created.imageImportId}`,
63 );
64 expect(created.location).toEqual("us-central1");
65 expect(created.cloudStorageUri).toContain("gs://");
66 expect(created.diskImageTargetDefaults?.imageName).toEqual("alchemy-imported-disk");
67 expect(created.diskImageTargetDefaults?.labels).toMatchObject({
68 env: "test",
69 });
70
71 const fetched = yield* vmmigration.getProjectsLocationsImageImports({
72 name: created.name,
73 });
74 expect(fetched.name).toEqual(created.name);
75 expect(fetched.diskImageTargetDefaults?.labels?.env).toEqual("test");
76 expect(fetched.diskImageTargetDefaults?.description).toContain("alchemy-id=");
77
78 yield* stack.destroy();
79 const gone = yield* waitUntilGone(
80 vmmigration.getProjectsLocationsImageImports({ name: created.name }),
81 );
82 expect(gone).toEqual("gone");
83 }).pipe(logLevel),
84 {
85 tags: ["provider:gcp", "provider:gcp:vmmigration", "live"],
86 timeout: 120_000,
87 },
88 );