@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 99 lines 3.31 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 SSH_KEY =
20 "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl alchemy-test";
21
22 const waitUntilGone = (name: string) =>
23 oracle.getProjectsLocationsDbSystems({ name }).pipe(
24 Effect.as("found" as const),
25 Effect.catchTag("NotFound", () => Effect.succeed("gone" as const)),
26 Effect.repeat({
27 schedule: Schedule.spaced("2 seconds"),
28 until: (status) => status === "gone",
29 times: 10,
30 }),
31 );
32
33 test.provider.skipIf(runLifecycle)(
34 "getProjectsLocationsDbSystems without Oracle Database enabled fails with ServiceDisabled",
35 (stack) =>
36 Effect.gen(function* () {
37 const { project } = yield* GcpEnvironment.current;
38
39 yield* stack.destroy();
40
41 const error = yield* Effect.flip(
42 oracle.getProjectsLocationsDbSystems({
43 name: `projects/${project}/locations/us-central1/dbSystems/alchemy-oracle-missing`,
44 }),
45 );
46 expect(error._tag).toEqual("ServiceDisabled");
47
48 yield* stack.destroy();
49 }).pipe(logLevel),
50 {
51 tags: ["provider:gcp", "provider:gcp:oracledatabase", "live"],
52 timeout: 90_000,
53 },
54 );
55
56 test.provider.skipIf(!runLifecycle)(
57 "create, update, and delete a db system",
58 (stack) =>
59 Effect.gen(function* () {
60 const { project } = yield* GcpEnvironment.current;
61
62 yield* stack.destroy();
63
64 const created = yield* stack.deploy(
65 Effect.gen(function* () {
66 return yield* GCP.OracleDatabase.DbSystem("BaseDb", {
67 location: "us-central1",
68 displayName: "alchemy-test-dbsystem",
69 odbSubnet: `projects/${project}/locations/us-central1/odbNetworks/missing/odbSubnets/client`,
70 shape: "VM.Standard.E4.Flex",
71 sshPublicKeys: [SSH_KEY],
72 computeCount: 2,
73 initialDataStorageSizeGb: 256,
74 licenseModel: "LICENSE_INCLUDED",
75 databaseEdition: "ENTERPRISE_EDITION",
76 labels: { env: "test" },
77 });
78 }),
79 );
80
81 expect(created.name).toContain("/dbSystems/");
82 expect(created.dbSystemId).toEqual(expect.any(String));
83 expect(created.labels).toMatchObject({ env: "test" });
84
85 const fetched = yield* oracle.getProjectsLocationsDbSystems({
86 name: created.name,
87 });
88 expect(fetched.name).toEqual(created.name);
89
90 yield* stack.destroy();
91
92 const gone = yield* waitUntilGone(created.name);
93 expect(gone).toEqual("gone");
94 }).pipe(logLevel),
95 {
96 tags: ["provider:gcp", "provider:gcp:oracledatabase", "live"],
97 timeout: 120_000,
98 },
99 );