Skip to content

Commit 3a4b9fa

Browse files
committed
test(codex): 覆盖线程限流响应解码
通过完整 thread/read、thread/resume 与 thread/rollback 响应验证限流错误的嵌套解码。\n\n将响应断言函数提升到模块作用域,避免每次测试重复编译 Schema。\n\n验证:聚焦 schema 测试与包类型检查通过。
1 parent 66d0cf1 commit 3a4b9fa

1 file changed

Lines changed: 41 additions & 9 deletions

File tree

‎packages/effect-codex-app-server/src/schema.test.ts‎

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import * as Schema from "effect/Schema";
44
import * as CodexSchema from "./schema.ts";
55

66
const isGetAccountResponse = Schema.is(CodexSchema.V2GetAccountResponse);
7+
const isThreadReadResponse = Schema.is(CodexSchema.V2ThreadReadResponse);
8+
const isThreadResumeResponse = Schema.is(CodexSchema.V2ThreadResumeResponse);
9+
const isThreadRollbackResponse = Schema.is(CodexSchema.V2ThreadRollbackResponse);
710

811
it("accepts Codex 0.150 multi-agent values", () => {
912
const schemas = [
@@ -75,15 +78,44 @@ it("accepts Codex 0.150 multi-agent values", () => {
7578
});
7679

7780
it("accepts Codex rate limit errors for thread responses", () => {
78-
const schemas = [
79-
CodexSchema.V2ThreadReadResponse__CodexErrorInfo,
80-
CodexSchema.V2ThreadResumeResponse__CodexErrorInfo,
81-
CodexSchema.V2ThreadRollbackResponse__CodexErrorInfo,
82-
];
83-
84-
for (const schema of schemas) {
85-
assert.equal(Schema.is(schema)("rateLimitExceeded"), true);
86-
}
81+
const failedThread = {
82+
cliVersion: "0.150.0",
83+
createdAt: 0,
84+
cwd: "/tmp/project",
85+
ephemeral: false,
86+
id: "thread-1",
87+
modelProvider: "openai",
88+
preview: "",
89+
sessionId: "session-1",
90+
source: "cli",
91+
status: { type: "idle" },
92+
turns: [
93+
{
94+
error: {
95+
codexErrorInfo: "rateLimitExceeded",
96+
message: "Rate limit exceeded",
97+
},
98+
id: "turn-1",
99+
items: [],
100+
status: "failed",
101+
},
102+
],
103+
updatedAt: 0,
104+
};
105+
assert.equal(isThreadReadResponse({ thread: failedThread }), true);
106+
assert.equal(
107+
isThreadResumeResponse({
108+
approvalPolicy: "never",
109+
approvalsReviewer: "user",
110+
cwd: "/tmp/project",
111+
model: "gpt-5.6-sol",
112+
modelProvider: "openai",
113+
sandbox: { type: "dangerFullAccess" },
114+
thread: failedThread,
115+
}),
116+
true,
117+
);
118+
assert.equal(isThreadRollbackResponse({ thread: failedThread }), true);
87119
});
88120

89121
it("accepts Codex 0.150 account plan values", () => {

0 commit comments

Comments
 (0)