mirror of
https://github.com/tinyhumansai/openhuman.git
synced 2026-07-28 21:44:38 +00:00
🧪 Add tests for summarize_rpc_result (#1418)
This commit is contained in:
@@ -82,3 +82,27 @@ fn is_sensitive_key(key: &str) -> bool {
|
||||
| "client_secret"
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use serde_json::json;
|
||||
|
||||
#[test]
|
||||
fn test_summarize_rpc_result() {
|
||||
assert_eq!(
|
||||
summarize_rpc_result(&json!({"b": 2, "a": 1})),
|
||||
"object(keys=a,b)"
|
||||
);
|
||||
assert_eq!(summarize_rpc_result(&json!({})), "object(keys=)");
|
||||
assert_eq!(summarize_rpc_result(&json!([1, 2, 3])), "array(len=3)");
|
||||
assert_eq!(summarize_rpc_result(&json!([])), "array(len=0)");
|
||||
assert_eq!(summarize_rpc_result(&json!("hello")), "string(len=5)");
|
||||
assert_eq!(summarize_rpc_result(&json!("")), "string(len=0)");
|
||||
assert_eq!(summarize_rpc_result(&json!(true)), "bool(true)");
|
||||
assert_eq!(summarize_rpc_result(&json!(false)), "bool(false)");
|
||||
assert_eq!(summarize_rpc_result(&json!(42)), "number(42)");
|
||||
assert_eq!(summarize_rpc_result(&json!(3.14)), "number(3.14)");
|
||||
assert_eq!(summarize_rpc_result(&json!(null)), "null");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user