test(api): 固化 Rust-Go RPC 契约

This commit is contained in:
2026-07-31 18:20:37 +08:00
parent 1e466d3374
commit df361cff28
17 changed files with 284 additions and 9 deletions
@@ -8951,6 +8951,36 @@ mod tests {
assert_eq!(value["error"]["code"], "BAT-ERR-700002");
}
#[test]
fn dispatch_unityfs_patch_methods_are_live_handlers_and_require_params() {
let temp = tempfile::TempDir::new().unwrap();
let control = new_daemon_control();
for method in [
"unityfs.patch_text_asset",
"unityfs.patch_string_field",
"unityfs.patch_field",
] {
let envelope = dispatch_rpc_method(
&rpc_request(method, None),
temp.path(),
&control,
&test_task_context(),
format!("req-test-{method}"),
);
let value = serde_json::to_value(&envelope).unwrap();
assert_eq!(value["ok"], false, "method={method}");
assert_eq!(value["error"]["code"], "BAT-ERR-700002", "method={method}");
assert_eq!(value["error"]["location"], method, "method={method}");
assert!(
value["error"]["message"]
.as_str()
.unwrap()
.contains("params 不能为空"),
"method={method}"
);
}
}
#[test]
fn dispatch_patch_apply_writes_text_patch_target() {
let temp = tempfile::TempDir::new().unwrap();