The best way to control Claude Code, Codex and more from any computer or phone

main
ts 63 lines 2.49 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 reconcile the same dataset and
20 // virtual field rather than piling up duplicates.
21 const DATASET_NAME = "alchemy-test-virtualfield-list";
22 const FIELD_NAME = "alchemy_list_status_class";
23
24 test.provider.skipIf(!hasAxiomCreds)(
25 "list enumerates the deployed virtual field",
26 (stack) =>
27 Effect.gen(function* () {
28 yield* stack.destroy();
29
30 const deployed = yield* stack.deploy(
31 Effect.gen(function* () {
32 const dataset = yield* Axiom.Dataset("ListDataset", {
33 name: DATASET_NAME,
34 });
35 return yield* Axiom.VirtualField("ListVirtualField", {
36 dataset: dataset.name,
37 name: FIELD_NAME,
38 description: "list() coverage marker",
39 expression: 'strcat(tostring(toint(status / 100)), "xx")',
40 type: "string",
41 });
42 }),
43 );
44
45 const provider = yield* Provider.findProvider(Axiom.VirtualField);
46 const all = yield* provider.list();
47
48 // `getVirtualFields` is per-dataset, so `list()` enumerates every dataset
49 // and fans out the per-dataset vfields list; the freshly created field
50 // must be present, hydrated into the exact `read` shape (so `.id` /
51 // `.dataset` are directly usable by `delete`).
52 const found = all.find((vf) => vf.id === deployed.id);
53 expect(found).toBeDefined();
54 expect(found?.name).toEqual(FIELD_NAME);
55 expect(found?.dataset).toEqual(DATASET_NAME);
56
57 yield* stack.destroy();
58 }).pipe(logLevel),
59 {
60 tags: ["provider:axiom", "provider:axiom:dataset", "provider:axiom:virtualfield", "live"],
61 timeout: 120_000,
62 },
63 );