修 rustfmt:resource_editor 新增用例按仓库格式折行

- `editor_api_rejection_reason_from_body` 用例里 3 处 `serde_json::json!(...).to_string().as_str()` 实参按 rustfmt 口径断行
- `editor_api_rejection_reason_from_body("<html>502</html>")` 断言折行
- 连带收掉 `remote-terminal-failed` 的 match 分支:该 arm 因上一提交改宽而超行宽,按 rustfmt 折成块
- `resource_editor.rs` 现在通过 `cargo fmt --manifest-path apps/ai-game-creator-shell/src-tauri/Cargo.toml -- --check`
This commit is contained in:
2026-09-11 12:21:04 +08:00
parent 8a1917b7e1
commit 775b3792cd
@@ -2597,7 +2597,9 @@ async fn submit_resource_edit_remote(
return Err(error.clone());
}
return Err(match editor_api_rejection_reason(response).await {
Some(reason) => format!("remote-terminal-failed: 资源编辑请求被拒绝:HTTP 400({reason}"),
Some(reason) => {
format!("remote-terminal-failed: 资源编辑请求被拒绝:HTTP 400({reason}")
}
None => "remote-terminal-failed: 资源编辑请求被拒绝:HTTP 400".to_string(),
});
}
@@ -5568,12 +5570,18 @@ mod tests {
"BAD_REQUEST 不重复透出错误码"
);
assert_eq!(
editor_api_rejection_reason_from_body(serde_json::json!({ "error": "直白文本" }).to_string().as_str()),
editor_api_rejection_reason_from_body(
serde_json::json!({ "error": "直白文本" })
.to_string()
.as_str()
),
Some("直白文本".to_string())
);
assert_eq!(
editor_api_rejection_reason_from_body(
serde_json::json!({ "message": "顶层文案" }).to_string().as_str()
serde_json::json!({ "message": "顶层文案" })
.to_string()
.as_str()
),
Some("顶层文案".to_string())
);
@@ -5581,11 +5589,16 @@ mod tests {
// 空值与非 JSON 正文不给用户编造原因。
assert_eq!(
editor_api_rejection_reason_from_body(
serde_json::json!({ "error": { "message": " " } }).to_string().as_str()
serde_json::json!({ "error": { "message": " " } })
.to_string()
.as_str()
),
None
);
assert_eq!(editor_api_rejection_reason_from_body("<html>502</html>"), None);
assert_eq!(
editor_api_rejection_reason_from_body("<html>502</html>"),
None
);
assert_eq!(editor_api_rejection_reason_from_body(""), None);
// 超长正文仍按 200 字符截断,避免把整段响应体塞进用户可见文案。