@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 72 lines 2.9 KB
Raw
1 import * as Axiom from "@alchemy.run/axiom";
2 import { expect } from "@alchemy.run/test";
3 import * as Test from "@alchemy.run/test/Alchemy";
4 import * as Output from "alchemy/Output";
5 import * as Provider from "alchemy/Provider";
6 import * as Effect from "effect/Effect";
7 import { MinimumLogLevel } from "effect/References";
8
9 const { test } = Test.make({ providers: Axiom.providers() });
10
11 const logLevel = Effect.provideService(MinimumLogLevel, process.env.DEBUG ? "Debug" : "Info");
12
13 // Axiom credentials are resolved via the AuthProvider (env method reads
14 // AXIOM_TOKEN / AXIOM_API_KEY). When neither is present the suite can't talk
15 // to the real API, so skipIf-gate the live list test. On an entitled run the
16 // failure mode without creds is an `AuthError`:
17 // "Axiom env credentials not found. Set AXIOM_TOKEN (or AXIOM_API_KEY)."
18 const hasAxiomCreds = !!(process.env.AXIOM_TOKEN || process.env.AXIOM_API_KEY);
19
20 // Deterministic names so re-runs reconcile the same resources rather than
21 // piling up duplicates. The monitor's APL query needs a real dataset target.
22 const DATASET_NAME = "alchemy-test-monitor-list";
23 const MONITOR_NAME = "alchemy-test-monitor-list";
24
25 test.provider.skipIf(!hasAxiomCreds)(
26 "list enumerates the deployed monitor",
27 (stack) =>
28 Effect.gen(function* () {
29 yield* stack.destroy();
30
31 const deployed = yield* stack.deploy(
32 Effect.gen(function* () {
33 const dataset = yield* Axiom.Dataset("ListDataset", {
34 name: DATASET_NAME,
35 });
36 return yield* Axiom.Monitor("ListMonitor", {
37 name: MONITOR_NAME,
38 description: "alchemy list() lifecycle op test",
39 type: "Threshold",
40 // Reference the dataset's OUTPUT so the monitor create waits for
41 // the dataset create (a bare name string carries no graph edge —
42 // Axiom rejects a monitor whose APL targets a missing dataset).
43 aplQuery: Output.interpolate`['${dataset.name}'] | summarize count()`,
44 intervalMinutes: 5,
45 rangeMinutes: 5,
46 operator: "Above",
47 threshold: 1,
48 notifierIds: [],
49 alertOnNoData: false,
50 resolvable: true,
51 });
52 }),
53 );
54
55 const provider = yield* Provider.findProvider(Axiom.Monitor);
56 const all = yield* provider.list();
57
58 // `getMonitors` returns the full account-wide list in one shot; the
59 // freshly created monitor must be present, hydrated into the exact `read`
60 // Attributes shape (so `.id` / `.type` are directly usable by `delete`).
61 const found = all.find((m) => m.id === deployed.id);
62 expect(found).toBeDefined();
63 expect(found?.name).toEqual(MONITOR_NAME);
64 expect(found?.type).toEqual("Threshold");
65
66 yield* stack.destroy();
67 }).pipe(logLevel),
68 {
69 tags: ["provider:axiom", "provider:axiom:dataset", "provider:axiom:monitor", "live"],
70 timeout: 120_000,
71 },
72 );