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

main
ts 69 lines 1.98 KB
Raw
1 import { describe, expect, test } from "@alchemy.run/test";
2 import * as Effect from "effect/Effect";
3 import {
4 adapterLayer,
5 resolve,
6 type DnsAdapter,
7 type DnsConfig,
8 type DnsZone,
9 } from "@/DNS/Adapter";
10 import * as Output from "@/Output";
11
12 const TYPE = "Test.DNS";
13
14 describe("DNS adapter binding", { tags: ["unit", "local"] }, () => {
15 test.effect("forwards deferred zones without resolving or replacing them", () =>
16 Effect.gen(function* () {
17 const deferredZone = Output.fromEffect(Effect.succeed("example.com"));
18 const config = {
19 type: TYPE,
20 zone: deferredZone,
21 } satisfies DnsConfig<typeof TYPE>;
22 const seen: DnsZone[] = [];
23 const adapter: DnsAdapter = {
24 alias: (_id, args) =>
25 Effect.sync(() => {
26 seen.push(args);
27 }),
28 aliasSet: () => Effect.die("unexpected aliasSet invocation"),
29 records: (_id, args) =>
30 Effect.sync(() => {
31 seen.push(args);
32 }),
33 };
34
35 const dns = yield* resolve(config).pipe(Effect.provide(adapterLayer(TYPE, adapter)));
36 yield* dns.alias("alias", {
37 name: "www.example.com",
38 target: { hostname: "target.example.com" },
39 });
40
41 expect(seen[0]?.zone).toBe(deferredZone);
42 }),
43 );
44
45 test.effect("leaves an omitted zone undefined", () =>
46 Effect.gen(function* () {
47 const seen: DnsZone[] = [];
48 const adapter: DnsAdapter = {
49 alias: (_id, args) =>
50 Effect.sync(() => {
51 seen.push(args);
52 }),
53 aliasSet: () => Effect.die("unexpected aliasSet invocation"),
54 records: (_id, args) =>
55 Effect.sync(() => {
56 seen.push(args);
57 }),
58 };
59
60 const dns = yield* resolve({ type: TYPE }).pipe(Effect.provide(adapterLayer(TYPE, adapter)));
61 yield* dns.alias("alias", {
62 name: "www.example.com",
63 target: { hostname: "target.example.com" },
64 });
65
66 expect(seen[0]?.zone).toBeUndefined();
67 }),
68 );
69 });