@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 90 lines 3.12 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 { withNetworkSlot } from "../networkQuota.ts";
7 import { logLevel, currentProject, runSlowLifecycle, waitUntilGone } from "./common.ts";
8
9 const { test } = Test.make({ providers: GCP.providers() });
10
11 test.provider(
12 "getProjectsLocationsPrivateConnections on a missing connection fails with a typed tag",
13 (stack) =>
14 Effect.gen(function* () {
15 const project = yield* currentProject;
16
17 yield* stack.destroy();
18
19 const error = yield* Effect.flip(
20 datamigration.getProjectsLocationsPrivateConnections({
21 name: `projects/${project}/locations/us-central1/privateConnections/alchemy-missing-pconn`,
22 }),
23 );
24 expect(error._tag).toEqual("NotFound");
25
26 yield* stack.destroy();
27 }).pipe(logLevel),
28 {
29 tags: ["provider:gcp", "provider:gcp:datamigration", "live"],
30 timeout: 90_000,
31 },
32 );
33
34 test.provider.skipIf(!runSlowLifecycle)(
35 "create and delete a private connection",
36 (stack) =>
37 Effect.gen(function* () {
38 const project = yield* currentProject;
39
40 yield* stack.destroy();
41
42 const created = yield* stack.deploy(
43 Effect.gen(function* () {
44 const network = yield* GCP.Compute.Network("DmsVpc", {
45 autoCreateSubnetworks: false,
46 });
47 const peering = yield* GCP.DataMigration.PrivateConnection("DmsPeer", {
48 location: "us-central1",
49 displayName: "dms-peer",
50 labels: { env: "test" },
51 skipValidation: true,
52 vpcPeeringConfig: {
53 vpcName: network.networkName,
54 subnet: "10.8.0.0/29",
55 },
56 });
57 return { network, peering };
58 }),
59 );
60
61 expect(created.peering.privateConnectionId).toEqual(expect.any(String));
62 expect(created.peering.name).toEqual(
63 `projects/${project}/locations/us-central1/privateConnections/${created.peering.privateConnectionId}`,
64 );
65 expect(created.peering.location).toEqual("us-central1");
66 expect(created.peering.displayName).toEqual("dms-peer");
67 expect(created.peering.labels).toMatchObject({ env: "test" });
68 expect(created.peering.vpcPeeringConfig?.subnet).toEqual("10.8.0.0/29");
69
70 const fetched = yield* datamigration.getProjectsLocationsPrivateConnections({
71 name: created.peering.name,
72 });
73 expect(fetched.name).toEqual(created.peering.name);
74 expect(fetched.displayName).toEqual("dms-peer");
75 expect(fetched.labels?.env).toEqual("test");
76 expect(fetched.vpcPeeringConfig?.subnet).toEqual("10.8.0.0/29");
77
78 yield* stack.destroy();
79 const gone = yield* waitUntilGone(
80 datamigration.getProjectsLocationsPrivateConnections({
81 name: created.peering.name,
82 }),
83 );
84 expect(gone).toEqual("gone");
85 }).pipe(logLevel, withNetworkSlot),
86 {
87 tags: ["provider:gcp", "provider:gcp:datamigration", "live"],
88 timeout: 1_500_000,
89 },
90 );