@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 92 lines 3.01 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 "getProjectsLocationsSources on a missing source 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.getProjectsLocationsSources({
19 name: `projects/${project}/locations/us-central1/sources/alchemy-missing-source`,
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 source",
34 (stack) =>
35 Effect.gen(function* () {
36 const project = yield* currentProject;
37 yield* stack.destroy();
38
39 const created = yield* stack.deploy(
40 Effect.gen(function* () {
41 return yield* GCP.VMMigration.Source("Aws", {
42 location: "us-central1",
43 description: "aws inventory",
44 labels: { env: "test" },
45 aws: dummyAws,
46 });
47 }),
48 );
49
50 expect(created.sourceId).toEqual(expect.any(String));
51 expect(created.name).toEqual(
52 `projects/${project}/locations/us-central1/sources/${created.sourceId}`,
53 );
54 expect(created.location).toEqual("us-central1");
55 expect(created.description).toEqual("aws inventory");
56 expect(created.labels).toMatchObject({ env: "test" });
57 expect(created.aws?.awsRegion).toEqual("us-east-1");
58
59 const fetched = yield* vmmigration.getProjectsLocationsSources({
60 name: created.name,
61 });
62 expect(fetched.name).toEqual(created.name);
63 expect(fetched.labels?.env).toEqual("test");
64 expect(fetched.aws?.awsRegion).toEqual("us-east-1");
65
66 const updated = yield* stack.deploy(
67 Effect.gen(function* () {
68 return yield* GCP.VMMigration.Source("Aws", {
69 sourceId: created.sourceId,
70 location: "us-central1",
71 description: "aws inventory v2",
72 labels: { env: "prod" },
73 aws: dummyAws,
74 });
75 }),
76 );
77
78 expect(updated.name).toEqual(created.name);
79 expect(updated.description).toEqual("aws inventory v2");
80 expect(updated.labels).toMatchObject({ env: "prod" });
81
82 yield* stack.destroy();
83 const gone = yield* waitUntilGone(
84 vmmigration.getProjectsLocationsSources({ name: created.name }),
85 );
86 expect(gone).toEqual("gone");
87 }).pipe(logLevel),
88 {
89 tags: ["provider:gcp", "provider:gcp:vmmigration", "live"],
90 timeout: 120_000,
91 },
92 );