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
| 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 | import { MinimumLogLevel } from "effect/References"; |
| 6 | import { awaitDrained, produce } from "./fixtures/queue-sink-client.ts"; |
| 7 | import { ResultQueue, SourceQueue } from "./fixtures/queue-sink-shared.ts"; |
| 8 | import QueueSinkWorker from "./fixtures/queue-sink-worker.ts"; |
| 9 | |
| 10 | // `dev: true` runs local providers behind the RPC sidecar proxy, matching |
| 11 | // the process topology of `alchemy dev` (see MakeOptions.sidecar). |
| 12 | const { test } = Test.make({ |
| 13 | providers: Cloudflare.providers(), |
| 14 | dev: true, |
| 15 | }); |
| 16 | |
| 17 | const logLevel = Effect.provideService(MinimumLogLevel, process.env.DEBUG ? "Debug" : "Info"); |
| 18 | |
| 19 | /** |
| 20 | * Under `alchemy dev` `QueueSinkBinding` rides the local Worker's native |
| 21 | * queue binding, so the same source → transform → sink fixture as the live |
| 22 | * suite runs entirely against the local broker. |
| 23 | */ |
| 24 | test.provider( |
| 25 | "local QueueSink drains a stream through source → transform → sink", |
| 26 | (stack) => |
| 27 | Effect.gen(function* () { |
| 28 | yield* stack.destroy(); |
| 29 | |
| 30 | const deployed = yield* stack.deploy( |
| 31 | Effect.gen(function* () { |
| 32 | const source = yield* SourceQueue; |
| 33 | const results = yield* ResultQueue; |
| 34 | const worker = yield* QueueSinkWorker; |
| 35 | return { |
| 36 | sourceId: source.queueId, |
| 37 | resultId: results.queueId, |
| 38 | url: worker.url.as<string>(), |
| 39 | }; |
| 40 | }), |
| 41 | ); |
| 42 | |
| 43 | // `dev:` ids prove no cloud queue was created; the worker is local. |
| 44 | expect(deployed.sourceId).toMatch(/^dev:/); |
| 45 | expect(deployed.resultId).toMatch(/^dev:/); |
| 46 | expect(deployed.url).toMatch(/^http:\/\/localhost:\d+$/); |
| 47 | |
| 48 | yield* produce(deployed.url, { run: "local", count: 250 }); |
| 49 | const snapshot = yield* awaitDrained(deployed.url, "local", 250); |
| 50 | expect(snapshot).toEqual({ distinct: 250, transformed: true }); |
| 51 | |
| 52 | yield* stack.destroy(); |
| 53 | }).pipe(logLevel), |
| 54 | { |
| 55 | tags: [ |
| 56 | "provider:cloudflare", |
| 57 | "provider:cloudflare:queue", |
| 58 | "provider:cloudflare:worker", |
| 59 | "local", |
| 60 | ], |
| 61 | timeout: 120_000, |
| 62 | }, |
| 63 | ); |