@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 64 lines 2.52 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 Provider from "alchemy/Provider";
5 import * as Effect from "effect/Effect";
6 import { MinimumLogLevel } from "effect/References";
7
8 const { test } = Test.make({ providers: Axiom.providers() });
9
10 const logLevel = Effect.provideService(MinimumLogLevel, process.env.DEBUG ? "Debug" : "Info");
11
12 // Axiom credentials are resolved via the AuthProvider (env method reads
13 // AXIOM_TOKEN / AXIOM_API_KEY). When neither is present the suite can't talk
14 // to the real API, so skipIf-gate the live list test. On an entitled run the
15 // failure mode without creds is an `AuthError`:
16 // "Axiom env credentials not found. Set AXIOM_TOKEN (or AXIOM_API_KEY)."
17 const hasAxiomCreds = !!(process.env.AXIOM_TOKEN || process.env.AXIOM_API_KEY);
18
19 // Deterministic names (no Date.now) so reruns target the same view/dataset and
20 // the start/end destroy bookends keep the org clean. A view's APL query is
21 // validated against existing datasets on create, so we stand up a backing
22 // dataset in the same stack.
23 const VIEW_NAME = "alchemy-list-test-view";
24 const DATASET_NAME = "alchemy-list-test-view-dataset";
25
26 test.provider.skipIf(!hasAxiomCreds)(
27 "list enumerates the deployed view",
28 (stack) =>
29 Effect.gen(function* () {
30 yield* stack.destroy();
31
32 const deployed = yield* stack.deploy(
33 Effect.gen(function* () {
34 const dataset = yield* Axiom.Dataset("ListViewDataset", {
35 name: DATASET_NAME,
36 });
37 return yield* Axiom.View("ListView", {
38 name: VIEW_NAME,
39 description: "alchemy list() lifecycle op test",
40 datasets: [dataset.name],
41 aplQuery: `['${DATASET_NAME}'] | take 1`,
42 });
43 }),
44 );
45
46 const provider = yield* Provider.findProvider(Axiom.View);
47 const all = yield* provider.list();
48
49 // `getViews` returns the full account-wide list in one shot; the freshly
50 // created view must be present, hydrated into the exact `read` Attributes
51 // shape (so `.id` / `.name` are directly usable by `delete`).
52 expect(all.some((v) => v.id === deployed.id)).toBe(true);
53
54 const row = all.find((v) => v.id === deployed.id)!;
55 expect(row.name).toEqual(VIEW_NAME);
56 expect(row.aplQuery).toEqual(deployed.aplQuery);
57
58 yield* stack.destroy();
59 }).pipe(logLevel),
60 {
61 tags: ["provider:axiom", "provider:axiom:dataset", "provider:axiom:view", "live"],
62 timeout: 120_000,
63 },
64 );