Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

project.test.ts

37 lines1.4 KB

1import { assert, it } from "@effect/vitest";
2​
3import { EnvironmentInternalError } from "@v12/contracts";
4​
5import {
6 ProjectLiveServerDeclaredResponseError,
7 ProjectLiveServerRequestError,
8 projectCommandErrorFromLiveServerRequest,
9} from "./project.ts";
10​
11it("maps declared server failures into structural project command errors", () => {
12 const cause = new EnvironmentInternalError({
13 code: "internal_error",
14 reason: "orchestration_snapshot_failed",
15 traceId: "trace-123",
16 });
17​
18 const error = projectCommandErrorFromLiveServerRequest(cause);
19​
20 assert.instanceOf(error, ProjectLiveServerDeclaredResponseError);
21 assert.strictEqual(error.operation, "callLiveServer");
22 assert.strictEqual(error.code, "internal_error");
23 assert.strictEqual(error.traceId, "trace-123");
24 assert.strictEqual(error.message, "Server request failed (internal_error, trace trace-123).");
25 assert.strictEqual(error.cause, cause);
26});
27​
28it("preserves unexpected server failures without deriving the message from them", () => {
29 const cause = new Error("credential abc123 was rejected");
30​
31 const error = projectCommandErrorFromLiveServerRequest(cause);
32​
33 assert.instanceOf(error, ProjectLiveServerRequestError);
34 assert.strictEqual(error.operation, "callLiveServer");
35 assert.strictEqual(error.message, "Failed to call the running server.");
36 assert.strictEqual(error.cause, cause);
37});