@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.09 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
19 const waitUntilGone = (name: string) =>
20 oracle.getProjectsLocationsCloudExadataInfrastructures({ name }).pipe(
21 Effect.as("found" as const),
22 Effect.catchTag("NotFound", () => Effect.succeed("gone" as const)),
23 Effect.repeat({
24 schedule: Schedule.spaced("2 seconds"),
25 until: (status) => status === "gone",
26 times: 10,
27 }),
28 );
29
30 test.provider.skipIf(runLifecycle)(
31 "getProjectsLocationsCloudExadataInfrastructures without Oracle Database enabled fails with ServiceDisabled",
32 (stack) =>
33 Effect.gen(function* () {
34 const { project } = yield* GcpEnvironment.current;
35
36 yield* stack.destroy();
37
38 const error = yield* Effect.flip(
39 oracle.getProjectsLocationsCloudExadataInfrastructures({
40 name: `projects/${project}/locations/us-central1/cloudExadataInfrastructures/alchemy-oracle-missing`,
41 }),
42 );
43 expect(error._tag).toEqual("ServiceDisabled");
44
45 yield* stack.destroy();
46 }).pipe(logLevel),
47 {
48 tags: ["provider:gcp", "provider:gcp:oracledatabase", "live"],
49 timeout: 90_000,
50 },
51 );
52
53 test.provider.skipIf(!runLifecycle)(
54 "create, update, and delete cloud exadata infrastructure",
55 (stack) =>
56 Effect.gen(function* () {
57 const { project } = yield* GcpEnvironment.current;
58
59 yield* stack.destroy();
60
61 const created = yield* stack.deploy(
62 Effect.gen(function* () {
63 return yield* GCP.OracleDatabase.CloudExadataInfrastructure("Exa", {
64 location: "us-central1",
65 displayName: "alchemy-test-exa",
66 shape: "Exadata.X9M",
67 computeCount: 2,
68 storageCount: 3,
69 labels: { env: "test" },
70 });
71 }),
72 );
73
74 expect(created.name).toContain("/cloudExadataInfrastructures/");
75 expect(created.cloudExadataInfrastructureId).toEqual(expect.any(String));
76 expect(created.labels).toMatchObject({ env: "test" });
77
78 const fetched = yield* oracle.getProjectsLocationsCloudExadataInfrastructures({
79 name: created.name,
80 });
81 expect(fetched.name).toEqual(created.name);
82
83 yield* stack.destroy();
84
85 const gone = yield* waitUntilGone(created.name);
86 expect(gone).toEqual("gone");
87 }).pipe(logLevel),
88 {
89 tags: ["provider:gcp", "provider:gcp:oracledatabase", "live"],
90 timeout: 120_000,
91 },
92 );