Unified · Split
| @@ -102,24 +102,21 @@ describe("promise/createExecutor", () => { · 101 unmodified lines | ||
| 102 | 102 | const ran = await executor.tools.invoke("ap.ctl.go", {}); |
| 103 | 103 | expect(ran).toBe("ran"); |
| 104 | 104 | |
| 105 | − // Override with a declining handler → rejects with ElicitationDeclinedError. | |
| 106 | − // Effect.runPromise rejects with a FiberFailure that wraps the typed | |
| 107 | − // error; both `name` and `message` carry the tag. | |
| 108 | − let caught: unknown; | |
| 109 | − try { | |
| 110 | − await executor.tools.invoke( | |
| 105 | + // Override with a declining handler -> rejects with ElicitationDeclinedError. | |
| 106 | + // Effect.runPromise rejects with a FiberFailure that carries the tag in | |
| 107 | + // the error name. | |
| 108 | + await expect( | |
| 109 | + executor.tools.invoke( | |
| 111 | 110 | "ap.ctl.go", |
| 112 | 111 | {}, |
| 113 | 112 | { |
| 114 | 113 | onElicitation: () => |
| 115 | 114 | Effect.succeed({ action: "decline" as const }) as any, |
| 116 | 115 | }, |
| 117 | − ); | |
| 118 | − } catch (e) { | |
| 119 | − caught = e; | |
| 120 | − } | |
| 121 | − expect(caught).toBeDefined(); | |
| 122 | − expect((caught as Error).name).toMatch(/ElicitationDeclinedError/); | |
| 116 | + ), | |
| 117 | + ).rejects.toMatchObject({ | |
| 118 | + name: expect.stringMatching(/ElicitationDeclinedError/), | |
| 119 | + }); | |
| 123 | 120 | |
| 124 | 121 | await executor.close(); |
| 125 | 122 | }); |
| @@ -45,7 +45,11 @@ describe("scopeAdapter — write rejection on scoped tables", () => { · 44 unmodified lines | ||
| 45 | 45 | const reason = result.cause.reasons.find(Cause.isFailReason); |
| 46 | 46 | const err = reason?.error ?? null; |
| 47 | 47 | expect(err).toBeInstanceOf(StorageError); |
| 48 | − expect((err as StorageError).message).toContain("not in the executor"); | |
| 48 | + expect(err).toEqual( | |
| 49 | + expect.objectContaining({ | |
| 50 | + message: expect.stringContaining("not in the executor"), | |
| 51 | + }), | |
| 52 | + ); | |
| 49 | 53 | }), |
| 50 | 54 | ); |
| 51 | 55 | |
| @@ -70,7 +74,11 @@ describe("scopeAdapter — write rejection on scoped tables", () => { · 18 unmodified lines | ||
| 70 | 74 | const reason = result.cause.reasons.find(Cause.isFailReason); |
| 71 | 75 | const err = reason?.error ?? null; |
| 72 | 76 | expect(err).toBeInstanceOf(StorageError); |
| 73 | − expect((err as StorageError).message).toContain("missing required"); | |
| 77 | + expect(err).toEqual( | |
| 78 | + expect.objectContaining({ | |
| 79 | + message: expect.stringContaining("missing required"), | |
| 80 | + }), | |
| 81 | + ); | |
| 74 | 82 | }), |
| 75 | 83 | ); |
| 76 | 84 | |
| @@ -116,26 +116,30 @@ describe("daemon bootstrap helpers", () => { · 115 unmodified lines | ||
| 116 | 116 | |
| 117 | 117 | it("falls back when preferred daemon port is occupied", async () => { |
| 118 | 118 | const blocker = createServer(); |
| 119 | − await new Promise<void>((resolve, reject) => { | |
| 120 | − blocker.once("error", reject); | |
| 121 | − blocker.listen({ port: 0, host: "127.0.0.1" }, () => resolve()); | |
| 122 | − }); | |
| 119 | + await Effect.runPromise(Effect.scoped(Effect.gen(function*() { | |
| 120 | + yield* Effect.acquireRelease( | |
| 121 | + Effect.callback<void, Error>((resume) => { | |
| 122 | + blocker.once("error", (error) => resume(Effect.fail(error))); | |
| 123 | + blocker.listen({ port: 0, host: "127.0.0.1" }, () => | |
| 124 | + resume(Effect.succeed(undefined))); | |
| 125 | + }), | |
| 126 | + () => Effect.promise(() => new Promise<void>((resolve) => { | |
| 127 | + blocker.close(() => resolve()); | |
| 128 | + })), | |
| 129 | + ); | |
| 123 | 130 | |
| 124 | − const occupied = (() => { | |
| 125 | − const address = blocker.address(); | |
| 126 | − return typeof address === "object" && address !== null ? address.port : 0; | |
| 127 | − })(); | |
| 131 | + const occupied = (() => { | |
| 132 | + const address = blocker.address(); | |
| 133 | + return typeof address === "object" && address !== null ? address.port : 0; | |
| 134 | + })(); | |
| 128 | 135 | |
| 129 | − try { | |
| 130 | − const picked = await Effect.runPromise( | |
| 136 | + const picked = yield* ( | |
| 131 | 137 | chooseDaemonPort({ |
| 132 | 138 | preferredPort: occupied, |
| 133 | 139 | hostname: "127.0.0.1", |
| 134 | − }), | |
| 140 | + }) | |
| 135 | 141 | ); |
| 136 | 142 | expect(picked).not.toBe(occupied); |
| 137 | − } finally { | |
| 138 | − await new Promise<void>((resolve) => blocker.close(() => resolve())); | |
| 139 | − } | |
| 143 | + }))); | |
| 140 | 144 | }); |
| 141 | 145 | }); |