Files
2026-10-03 13:51:03 -07:00

53 lines
1.7 KiB
Rust

//! Tests for `LogRecord::ToolSummary`. Do not edit.
use bxcore::{CallId, DataClass, LogRecord, Timestamp};
fn ts() -> Timestamp {
Timestamp::parse("2026-09-18T08:00:00.000Z").unwrap()
}
#[test]
fn tool_summary_round_trips() {
let rec = LogRecord::ToolSummary {
time: ts(),
call: CallId(3),
tool_call_id: "call_x".to_string(),
content: "the page is about tea".to_string(),
class: DataClass::Public,
untrusted: true,
};
let line = serde_json::to_string(&rec).unwrap();
assert!(line.contains("\"type\":\"tool_summary\""), "{line}");
let back: LogRecord = serde_json::from_str(&line).unwrap();
assert_eq!(back, rec);
}
#[test]
fn unknown_fields_are_refused() {
let line = r#"{"type":"tool_summary","time":"2026-09-18T08:00:00.000Z","call":3,"tool_call_id":"c","content":"x","class":"public","untrusted":false,"extra":1}"#;
assert!(serde_json::from_str::<LogRecord>(line).is_err());
}
#[test]
fn field_order_is_the_struct_order() {
let rec = LogRecord::ToolSummary {
time: ts(),
call: CallId(1),
tool_call_id: "c".to_string(),
content: "x".to_string(),
class: DataClass::Private,
untrusted: false,
};
let line = serde_json::to_string(&rec).unwrap();
let time = line.find("\"time\"").unwrap();
let call = line.find("\"call\"").unwrap();
let id = line.find("\"tool_call_id\"").unwrap();
let content = line.find("\"content\"").unwrap();
let class = line.find("\"class\"").unwrap();
let untrusted = line.find("\"untrusted\"").unwrap();
assert!(
time < call && call < id && id < content && content < class && class < untrusted,
"{line}"
);
}