The best way to control Claude Code, Codex and more from any computer or phone
| 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 notifier name so re-runs reconcile the same notifier rather |
| 20 | // than piling up duplicates. |
| 21 | const NOTIFIER_NAME = "alchemy-test-notifier-list"; |
| 22 | |
| 23 | test.provider.skipIf(!hasAxiomCreds)( |
| 24 | "list enumerates the deployed notifier", |
| 25 | (stack) => |
| 26 | Effect.gen(function* () { |
| 27 | yield* stack.destroy(); |
| 28 | |
| 29 | const deployed = yield* stack.deploy( |
| 30 | Effect.gen(function* () { |
| 31 | return yield* Axiom.Notifier("ListNotifier", { |
| 32 | name: NOTIFIER_NAME, |
| 33 | properties: { |
| 34 | email: { emails: ["sre@example.com"] }, |
| 35 | }, |
| 36 | }); |
| 37 | }), |
| 38 | ); |
| 39 | |
| 40 | const provider = yield* Provider.findProvider(Axiom.Notifier); |
| 41 | const all = yield* provider.list(); |
| 42 | |
| 43 | // `getNotifiers` returns the full account-wide list in one shot; the |
| 44 | // freshly created notifier must be present, hydrated into the exact |
| 45 | // `read` shape (so `.id` / `.name` are directly usable by `delete`). |
| 46 | const found = all.find((n) => n.id === deployed.id); |
| 47 | expect(found).toBeDefined(); |
| 48 | expect(found?.name).toEqual(NOTIFIER_NAME); |
| 49 | |
| 50 | yield* stack.destroy(); |
| 51 | }).pipe(logLevel), |
| 52 | { |
| 53 | tags: ["provider:axiom", "provider:axiom:notifier", "live"], |
| 54 | timeout: 120_000, |
| 55 | }, |
| 56 | ); |