fix(delivery/mcp): 补 get_delivery_status 经 scoped dispatch 转发 pr_number/branch 的回归测试(P3-F 审查)
使者回传 #203 的症状是「传 pr_number 也不起作用」,但原有 MCP 层测试只覆盖非法参数报错, dispatch 若丢弃已解析的查询目标、改传默认值,全部测试仍通过。新增 scoped dispatch 正向测试, 断言 pr_number/branch/null 分别得到 pull_request/branch/local_branch 目标;已用变异 (dispatch 改传 DeliveryQuery::default())确认该测试会失败。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
1e3989d0d7
commit
df5832f41b
@ -2680,6 +2680,67 @@ mod tests {
|
|||||||
assert!(text.contains("feat/delivery-status-by-pr"), "{text}");
|
assert!(text.contains("feat/delivery-status-by-pr"), "{text}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 使者回传 #203 的症状正是「传 pr_number 也不起作用」:经 scoped dispatch 断言
|
||||||
|
/// pr_number/branch 真正到达能力本体(未绑定 Gitea,不发网络请求)。
|
||||||
|
#[tokio::test]
|
||||||
|
async fn delivery_status_dispatch_forwards_pr_and_branch_targets() {
|
||||||
|
db::init_test_pool();
|
||||||
|
let base = temp_base("delivery_target_dispatch");
|
||||||
|
{
|
||||||
|
let conn = db::pool().get().unwrap();
|
||||||
|
conn.execute(
|
||||||
|
"INSERT OR IGNORE INTO project_profiles (id, name) VALUES ('delivery-target-profile', 'Delivery target fixture')",
|
||||||
|
[],
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
conn.execute(
|
||||||
|
"INSERT OR IGNORE INTO project_workspaces (id, profile_id, win_path) VALUES ('delivery-target', 'delivery-target-profile', ?1)",
|
||||||
|
[base.to_str().unwrap()],
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
let target_of = |result: &Value| {
|
||||||
|
assert_ne!(result["isError"], true, "{result}");
|
||||||
|
result["structuredContent"]["target"].clone()
|
||||||
|
};
|
||||||
|
|
||||||
|
let by_pr = tools_call_for_project(
|
||||||
|
Some(&json!({"name": "get_delivery_status", "arguments": {
|
||||||
|
"pr_number": 31, "branch": "feat/worktree"
|
||||||
|
}})),
|
||||||
|
"delivery-target",
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
let target = target_of(&by_pr);
|
||||||
|
assert_eq!(target["mode"], "pull_request", "{by_pr}");
|
||||||
|
assert_eq!(target["pr_number"], 31, "{by_pr}");
|
||||||
|
assert_eq!(
|
||||||
|
by_pr["structuredContent"]["pull_request"]["state"],
|
||||||
|
"not_configured"
|
||||||
|
);
|
||||||
|
|
||||||
|
let by_branch = tools_call_for_project(
|
||||||
|
Some(&json!({"name": "get_delivery_status", "arguments": {
|
||||||
|
"branch": "feat/worktree"
|
||||||
|
}})),
|
||||||
|
"delivery-target",
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
let target = target_of(&by_branch);
|
||||||
|
assert_eq!(target["mode"], "branch", "{by_branch}");
|
||||||
|
assert_eq!(target["branch"], "feat/worktree", "{by_branch}");
|
||||||
|
|
||||||
|
let default = tools_call_for_project(
|
||||||
|
Some(&json!({"name": "get_delivery_status", "arguments": {
|
||||||
|
"pr_number": null, "branch": null
|
||||||
|
}})),
|
||||||
|
"delivery-target",
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
assert_eq!(target_of(&default)["mode"], "local_branch", "{default}");
|
||||||
|
let _ = std::fs::remove_dir_all(&base);
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn delivery_status_tool_requires_project_id() {
|
async fn delivery_status_tool_requires_project_id() {
|
||||||
let result = tools_call(Some(&json!({
|
let result = tools_call(Some(&json!({
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user