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

main
ts 36 lines 1.31 KB
Raw
1 import * as Cloudflare from "@alchemy.run/cloudflare";
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: Cloudflare.providers() });
9
10 const logLevel = Effect.provideService(MinimumLogLevel, process.env.DEBUG ? "Debug" : "Info");
11
12 // Canonical `list()` test (account-scoped collection): deploy a real D1
13 // database, resolve the provider from context via the typed
14 // `Provider.findProvider`, call `list()`, and assert the deployed database
15 // appears in the exhaustively-paginated result.
16 test.provider(
17 "list enumerates the deployed database",
18 (stack) =>
19 Effect.gen(function* () {
20 yield* stack.destroy();
21
22 const database = yield* stack.deploy(
23 Effect.gen(function* () {
24 return yield* Cloudflare.D1.Database("ListDatabase");
25 }),
26 );
27
28 const provider = yield* Provider.findProvider(Cloudflare.D1.Database);
29 const all = yield* provider.list();
30
31 expect(all.some((db) => db.databaseId === database.databaseId)).toBe(true);
32
33 yield* stack.destroy();
34 }).pipe(logLevel),
35 { tags: ["provider:cloudflare", "provider:cloudflare:d1", "live"] },
36 );