@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 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.getProjectsLocationsExascaleDbStorageVaults({ 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 "getProjectsLocationsExascaleDbStorageVaults 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.getProjectsLocationsExascaleDbStorageVaults({
40 name: `projects/${project}/locations/us-central1/exascaleDbStorageVaults/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 an exascale db storage vault",
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.ExascaleDbStorageVault("Vault", {
64 location: "us-central1",
65 displayName: "alchemyvault",
66 totalSizeGbs: 300,
67 labels: { env: "test" },
68 });
69 }),
70 );
71
72 expect(created.name).toContain("/exascaleDbStorageVaults/");
73 expect(created.exascaleDbStorageVaultId).toEqual(expect.any(String));
74 expect(created.labels).toMatchObject({ env: "test" });
75
76 const fetched = yield* oracle.getProjectsLocationsExascaleDbStorageVaults({
77 name: created.name,
78 });
79 expect(fetched.name).toEqual(created.name);
80
81 yield* stack.destroy();
82
83 const gone = yield* waitUntilGone(created.name);
84 expect(gone).toEqual("gone");
85 }).pipe(logLevel),
86 {
87 tags: ["provider:gcp", "provider:gcp:oracledatabase", "live"],
88 timeout: 120_000,
89 },
90 );