Files
sausage/interface/tests/review_client.rs
T
surma c728429d04 sdk, agent: review fixes (T18R)
- The serve loop ends the process after EOF or exit_after_response,
  also with background tasks or listeners.
- One schema generator per direction for the whole document, so types
  with the same name get distinct names.
- The agent gives the complete error (code, message, data) to the
  model, writes SKIP only after a successful request, caps tool output
  at 64 KiB, writes each history line in one write, and skips a damaged
  line.
- Endpoints skip blank and non-RPC lines. client_rs does not panic.
- #[must_use] on builders and the lock guard; #[schemars] attributes
  and duplicate hooks are compile errors; raw identifiers; -32000 for
  local SDK errors; x-sausage-params only for methods with params.
2026-10-23 02:38:35 +01:00

30 lines
1.0 KiB
Rust

//! Client generation accepts unusual method names and reports invalid parameter names.
use serde_json::json;
#[test]
fn underscore_segments_and_empty_params_do_not_panic() {
for name in ["_internal", "a__b", "__"] {
for params in [
json!([]),
json!([{"name":"value","schema":{"type":"string"}}]),
] {
let doc = json!({"methods":[{"name":name,"params":params,"result":{"schema":{"type":"null"}}}]});
syn::parse_file(&sausage_interface::client_rs("probe", &doc).unwrap()).unwrap();
}
}
}
#[test]
fn unnamed_param_returns_error() {
let doc = json!({"methods":[{"name":"call","params":[{"schema":{"type":"string"}}],"result":{"schema":{"type":"null"}}}]});
assert!(sausage_interface::client_rs("probe", &doc).is_err());
}
#[test]
fn invalid_endpoint_identifier_returns_error() {
assert!(
sausage_interface::client_rs(
"probe",
&json!({"x-sausage-endpoints":{"bad-name":{"methods":[]}}})
)
.is_err()
);
}