@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 107 lines 3.47 KB
Raw
1 import * as GCP from "@alchemy.run/gcp";
2 import { GcpEnvironment } from "@alchemy.run/gcp/Environment";
3 import { expect } from "@alchemy.run/test";
4 import * as Test from "@alchemy.run/test/Alchemy";
5 import * as oracle from "@distilled.cloud/gcp/oracledatabase_v1";
6 import * as Effect from "effect/Effect";
7 import { MinimumLogLevel } from "effect/References";
8 import * as Schedule from "effect/Schedule";
9
10 const { test } = Test.make({ providers: GCP.providers() });
11
12 const logLevel = Effect.provideService(MinimumLogLevel, process.env.DEBUG ? "Debug" : "Info");
13
14 // Oracle Database@Google Cloud is not enabled in the test project
15 // (ServiceDisabled) and needs an Oracle Cloud subscription. Set
16 // GCP_TEST_ORACLE=1 in a project that has one.
17 const runLifecycle = !!process.env.GCP_TEST_ORACLE && !process.env.FAST;
18 const location = "us-central1";
19
20 const waitUntilGone = (name: string) =>
21 oracle.getProjectsLocationsOdbNetworks({ name }).pipe(
22 Effect.as("found" as const),
23 Effect.catchTag("NotFound", () => Effect.succeed("gone" as const)),
24 Effect.repeat({
25 schedule: Schedule.spaced("2 seconds"),
26 until: (status) => status === "gone",
27 times: 10,
28 }),
29 );
30
31 test.provider.skipIf(runLifecycle)(
32 "getProjectsLocationsOdbNetworks without Oracle Database enabled fails with ServiceDisabled",
33 (stack) =>
34 Effect.gen(function* () {
35 const { project } = yield* GcpEnvironment.current;
36
37 yield* stack.destroy();
38
39 const error = yield* Effect.flip(
40 oracle.getProjectsLocationsOdbNetworks({
41 name: `projects/${project}/locations/${location}/odbNetworks/alchemy-odb-missing`,
42 }),
43 );
44 expect(error._tag).toEqual("ServiceDisabled");
45
46 yield* stack.destroy();
47 }).pipe(logLevel),
48 {
49 tags: ["provider:gcp", "provider:gcp:oracledatabase", "live"],
50 timeout: 90_000,
51 },
52 );
53
54 test.provider.skipIf(!runLifecycle)(
55 "create, update, and delete an odb network",
56 (stack) =>
57 Effect.gen(function* () {
58 const { project } = yield* GcpEnvironment.current;
59
60 yield* stack.destroy();
61
62 const created = yield* stack.deploy(
63 Effect.gen(function* () {
64 return yield* GCP.OracleDatabase.OdbNetwork("OracleNet", {
65 location,
66 network: "default",
67 labels: { env: "test" },
68 });
69 }),
70 );
71
72 expect(created.name).toContain("/odbNetworks/");
73 expect(created.odbNetworkId).toEqual(expect.any(String));
74 expect(created.location).toEqual(location);
75 expect(created.network).toContain("/networks/");
76 expect(created.labels).toMatchObject({ env: "test" });
77
78 const fetched = yield* oracle.getProjectsLocationsOdbNetworks({
79 name: created.name,
80 });
81 expect(fetched.name).toEqual(created.name);
82 expect(fetched.labels?.env).toEqual("test");
83
84 const updated = yield* stack.deploy(
85 Effect.gen(function* () {
86 return yield* GCP.OracleDatabase.OdbNetwork("OracleNet", {
87 odbNetworkId: created.odbNetworkId,
88 location,
89 network: "default",
90 labels: { env: "prod", role: "oracle" },
91 });
92 }),
93 );
94
95 expect(updated.name).toEqual(created.name);
96 expect(updated.odbNetworkId).toEqual(created.odbNetworkId);
97
98 yield* stack.destroy();
99
100 const gone = yield* waitUntilGone(created.name);
101 expect(gone).toEqual("gone");
102 }).pipe(logLevel),
103 {
104 tags: ["provider:gcp", "provider:gcp:oracledatabase", "live"],
105 timeout: 120_000,
106 },
107 );