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

main
ts 57 lines 1.96 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 import { MinimumLogLevel } from "effect/References";
6 import { expectUrlContains } from "../Utils/Http.ts";
7 import EnvEffectWorker from "./fixtures/env/effect.ts";
8
9 // Deploy-time `Config` reads in the fixture's Init must resolve.
10 process.env.CONFIG_STR ??= "config-string-value";
11 process.env.CONFIG_NUM ??= "1234";
12 process.env.CONFIG_REDACTED ??= "config-redacted-value";
13 process.env.CONFIG_REDACTED_INIT ??= "config-redacted-init-value";
14 process.env.CONFIG_NESTED_HOST ??= "config-nested-host-value";
15
16 // `dev: true` runs local providers behind the RPC sidecar proxy by default,
17 // matching the process topology of the real `alchemy dev` command.
18 const { test } = Test.make({
19 providers: Cloudflare.providers(),
20 dev: true,
21 });
22
23 const logLevel = Effect.provideService(MinimumLogLevel, process.env.DEBUG ? "Debug" : "Info");
24
25 test.provider(
26 "local effect worker reads env strings that parse as JSON as strings (#2847)",
27 (stack) =>
28 Effect.gen(function* () {
29 yield* stack.destroy();
30
31 const worker = yield* stack.deploy(EnvEffectWorker);
32 expect(worker.url).toMatch(/^http:\/\/localhost:\d+$/);
33
34 const body = yield* expectUrlContains(`${worker.url}/json-strings`, '"PLAIN"', {
35 timeout: "60 seconds",
36 label: "local effect env-worker /json-strings",
37 });
38 const strings = {
39 JSON_FALSE: "false",
40 JSON_NUM: "42",
41 JSON_NULL: "null",
42 JSON_OBJ: '{"a":1}',
43 PLAIN: "my-queue",
44 };
45 expect(JSON.parse(body)).toEqual({
46 init: { ...strings, JSON_FALSE_BOOL: false },
47 runtime: { ...strings, JSON_FALSE_BOOL: false },
48 env: strings,
49 });
50
51 yield* stack.destroy();
52 }).pipe(logLevel),
53 {
54 tags: ["provider:cloudflare", "provider:cloudflare:worker", "local"],
55 timeout: 180_000,
56 },
57 );