Open History to see the last commit
1import { describe, expect, it } from "vite-plus/test";
2
3import {
4 EnvironmentAuthInvalidError,
5 EnvironmentInternalError,
6 EnvironmentOperationForbiddenError,
7 EnvironmentRequestInvalidError,
8 EnvironmentResourceNotFoundError,
9 EnvironmentScopeRequiredError,
10} from "./environmentHttp.ts";
11
12const traceId = "trace-1";
13
14describe("environment HTTP errors", () => {
15 it("each carries a message that names its reason", () => {
16 const errors = [
17 new EnvironmentRequestInvalidError({
18 code: "invalid_request",
19 reason: "invalid_command",
20 traceId,
21 }),
22 new EnvironmentAuthInvalidError({
23 code: "auth_invalid",
24 reason: "missing_credential",
25 traceId,
26 }),
27 new EnvironmentScopeRequiredError({
28 code: "insufficient_scope",
29 requiredScope: "orchestration:read",
30 traceId,
31 }),
32 new EnvironmentOperationForbiddenError({
33 code: "operation_forbidden",
34 reason: "current_session_revoke_not_allowed",
35 traceId,
36 }),
37 new EnvironmentResourceNotFoundError({
38 code: "not_found",
39 reason: "thread_not_found",
40 traceId,
41 }),
42 new EnvironmentInternalError({
43 code: "internal_error",
44 reason: "orchestration_snapshot_failed",
45 traceId,
46 }),
47 ] as const;
48 const details = [
49 "invalid_command",
50 "missing_credential",
51 "orchestration:read",
52 "current_session_revoke_not_allowed",
53 "thread_not_found",
54 "orchestration_snapshot_failed",
55 ];
56 errors.forEach((error, index) => {
57 expect(error.message).toContain(details[index]);
58 });
59 });
60});