use super::error::Error;
#[test]
fn a_default_refusal_reason_is_written_once() {
let error = Error::new(503, "mcp_http_busy", "The request capacity is reached");
assert_eq!(
error.to_string(),
"mcp_http_busy: The request capacity is reached"
);
assert_eq!(
error
.to_string()
.matches("The request capacity is reached")
.count(),
1
);
}
#[test]
fn a_store_refusal_is_named_in_the_log_line_and_never_in_the_answer()
-> Result<(), serde_json::Error> {
let error = Error::new(
503,
"mcp_store_unavailable",
"The store did not take the presented Lys pass",
)
.with_store_refusal("lys_could_not_be_asked");
assert_eq!(
error.to_string(),
"mcp_store_unavailable: The store did not take the presented Lys pass; cause=store:lys_could_not_be_asked"
);
assert!(!serde_json::to_string(&error)?.contains("lys_could_not_be_asked"));
let odd = Error::new(503, "mcp_store_unavailable", "x").with_store_refusal("Bearer eyJ.secret");
assert_eq!(
odd.to_string(),
"mcp_store_unavailable: x; cause=store:unnamed"
);
Ok(())
}