fix: 修复 PDD 页面误判与失败回执 (#35)

This commit is contained in:
chengma
2026-08-07 17:58:30 +08:00
parent 51c2292be1
commit c59b4b0d59
11 changed files with 267 additions and 11 deletions
+1
View File
@@ -210,6 +210,7 @@ func SubmitFailure(db *sql.DB, taskID, clientID, idemKey string, rawBody []byte)
}
return map[string]any{
"accepted": true,
"result_id": newID(),
"task_status": string(newStatus),
"accepted_at": model.NowISO(),
}, nil
+9 -1
View File
@@ -435,9 +435,17 @@ func TestSubmitFailure_状态映射(t *testing.T) {
body := `{"task_version":1,"attempt_id":"a-1","status":"` + tc.reported +
`","error":{"code":"PDD_PAGE_TIMEOUT","message":"页面超时"}}`
if _, err := SubmitFailure(db, "TASK-A", "client-001", "k", []byte(body)); err != nil {
response, err := SubmitFailure(db, "TASK-A", "client-001", "k", []byte(body))
if err != nil {
t.Fatalf("提交失败结果出错: %v", err)
}
var receipt map[string]any
if err := json.Unmarshal([]byte(response), &receipt); err != nil {
t.Fatalf("失败响应不是 JSON: %v", err)
}
if receipt["result_id"] == "" || receipt["result_id"] == nil {
t.Error("失败响应 result_id 不应为空")
}
if s := taskStatus(t, db, "TASK-A"); s != tc.want {
t.Errorf("%s 应映射为 %s,实际 %s", tc.reported, tc.want, s)
}