@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 65 lines 2.27 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 metastore from "@distilled.cloud/gcp/metastore_v1";
6 import * as Effect from "effect/Effect";
7 import { MinimumLogLevel } from "effect/References";
8 import { isServiceEnabled } from "../ServiceState.ts";
9
10 const { test } = Test.make({ providers: GCP.providers() });
11
12 const logLevel = Effect.provideService(MinimumLogLevel, process.env.DEBUG ? "Debug" : "Info");
13
14 test.provider(
15 "getProjectsLocationsFederations on a missing federation fails with a typed tag",
16 (stack) =>
17 Effect.gen(function* () {
18 const { project } = yield* GcpEnvironment.current;
19 yield* stack.destroy();
20
21 const error = yield* Effect.flip(
22 metastore.getProjectsLocationsFederations({
23 name: `projects/${project}/locations/us-central1/federations/alchemy-missing-federation`,
24 }),
25 );
26 expect(["ServiceDisabled", "NotFound"]).toContain(error._tag);
27
28 yield* stack.destroy();
29 }).pipe(logLevel),
30 { tags: ["provider:gcp", "provider:gcp:metastore", "live"], timeout: 90_000 },
31 );
32
33 test.provider(
34 "create is rejected when the Dataproc Metastore API is disabled",
35 (stack) =>
36 Effect.gen(function* () {
37 // Only meaningful while the API is disabled: enabled, the create would
38 // provision a real resource.
39 if (yield* isServiceEnabled("metastore.googleapis.com")) return;
40 const { project } = yield* GcpEnvironment.current;
41 yield* stack.destroy();
42
43 const error = yield* Effect.flip(
44 stack.deploy(
45 Effect.gen(function* () {
46 return yield* GCP.Metastore.Federation("Lakehouse", {
47 location: "us-central1",
48 version: "3.1.2",
49 backendMetastores: {
50 "1": {
51 name: `projects/${project}`,
52 metastoreType: "BIGQUERY",
53 },
54 },
55 labels: { env: "test" },
56 });
57 }),
58 ),
59 );
60 expect(error._tag).toEqual("ServiceDisabled");
61
62 yield* stack.destroy();
63 }).pipe(logLevel),
64 { tags: ["provider:gcp", "provider:gcp:metastore", "live"], timeout: 90_000 },
65 );