@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 54 lines 1.84 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 Effect from "effect/Effect";
5
6 const { test } = Test.make({ providers: Cloudflare.providers() });
7
8 const script = `export default { fetch() { return new Response("ok"); } };`;
9
10 /**
11 * Deploy-time binding validation rejects a script upload whose bindings
12 * reference a resource that doesn't exist. The Durable Object
13 * cross-script binding is the one deterministic engine-level trigger:
14 * `scriptName` is a plain string, so a stack can name a script that was
15 * never deployed. (Every other binding type can only reference a
16 * resource declared in the stack, and its reconciler heals a missing
17 * target before the Worker deploys — those hit not-found only via
18 * propagation races, which `putWorkerScript`'s bounded retry rides
19 * out.)
20 *
21 * The deploy must fail with the resource-specific typed error after the
22 * bounded retry exhausts — not an UnknownCloudflareError, and not a
23 * success.
24 */
25 test.provider(
26 "durable object binding to a script that doesn't exist surfaces the typed error",
27 (stack) =>
28 Effect.gen(function* () {
29 yield* stack.destroy();
30
31 const error = yield* stack
32 .deploy(
33 Effect.gen(function* () {
34 return yield* Cloudflare.Worker("do-consumer-worker", {
35 script,
36 env: {
37 Counter: Cloudflare.DurableObject("Counter", {
38 scriptName: "alchemy-test-nonexistent-do-host",
39 }),
40 },
41 });
42 }),
43 )
44 .pipe(Effect.flip);
45
46 expect(error._tag).toEqual("DurableObjectClassNotFound");
47
48 yield* stack.destroy();
49 }),
50 {
51 tags: ["provider:cloudflare", "provider:cloudflare:worker", "live"],
52 timeout: 240_000,
53 },
54 );