@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 62 lines 2.62 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 dataset name so re-runs reconcile the same dataset rather than
20 // piling up duplicates (no Date.now in physical names).
21 const DATASET_NAME = "alchemy-test-dataset-list";
22
23 // Canonical `list()` test (account collection): Axiom exposes a single
24 // org-wide `GET /v2/datasets` op, so `list()` enumerates every dataset and
25 // hydrates each row into the exact `read` Attributes shape.
26 test.provider.skipIf(!hasAxiomCreds)(
27 "list enumerates the deployed dataset",
28 (stack) =>
29 Effect.gen(function* () {
30 yield* stack.destroy();
31
32 const deployed = yield* stack.deploy(
33 Effect.gen(function* () {
34 return yield* Axiom.Dataset("ListDataset", {
35 name: DATASET_NAME,
36 description: "alchemy list() lifecycle op test",
37 });
38 }),
39 );
40
41 const provider = yield* Provider.findProvider(Axiom.Dataset);
42 const all = yield* provider.list();
43
44 // `getDatasets` returns the full account-wide list in one shot; the
45 // freshly created dataset must be present, hydrated into the exact
46 // `read` shape (so `.id` / `.name` are directly usable by `delete`).
47 const found = all.find((d) => d.id === deployed.id);
48 expect(found).toBeDefined();
49 expect(found?.name).toEqual(DATASET_NAME);
50 expect(found?.kind).toEqual(deployed.kind);
51 expect(found?.edgeDeployment).toEqual(deployed.edgeDeployment);
52 expect(found?.edgeDeploymentUrl).toEqual(deployed.edgeDeploymentUrl);
53 expect(found?.otelEndpoint).toEqual(deployed.edgeDeploymentUrl.replace(/\/$/, ""));
54 expect(found?.otelTracesEndpoint).toEqual(deployed.otelTracesEndpoint);
55
56 yield* stack.destroy();
57 }).pipe(logLevel),
58 {
59 tags: ["provider:axiom", "provider:axiom:dataset", "live"],
60 timeout: 120_000,
61 },
62 );