test(TASK-042): prove serialize leg for old-session blocks and YAML round-trip
- assert old Thinking/RedactedThinking blocks re-serialize to the original wire shape, proving both legs of old-session compat - add serde_yaml round-trip test for Vec<ThinkingBlock> covering the on-disk session format, including a Reasoning block with summary payload and the encrypted_content: None omitted-field case
This commit is contained in:
1 file changed
+29
-1
+29
-1
@@ -288,7 +288,7 @@ mod tests {
|
||||
{ "type": "redacted_thinking", "data": "b64data" },
|
||||
]);
|
||||
|
||||
let blocks: Vec<ThinkingBlock> = serde_json::from_value(json).unwrap();
|
||||
let blocks: Vec<ThinkingBlock> = serde_json::from_value(json.clone()).unwrap();
|
||||
|
||||
assert!(
|
||||
matches!(&blocks[0], ThinkingBlock::Thinking { thinking, signature } if thinking == "hmm" && signature == "sig123")
|
||||
@@ -296,6 +296,7 @@ mod tests {
|
||||
assert!(
|
||||
matches!(&blocks[1], ThinkingBlock::RedactedThinking { data } if data == "b64data")
|
||||
);
|
||||
assert_eq!(serde_json::to_value(&blocks).unwrap(), json);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -330,4 +331,31 @@ mod tests {
|
||||
);
|
||||
assert_eq!(serde_json::to_value(&block).unwrap(), json);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn thinking_blocks_round_trip_through_yaml() {
|
||||
let json = json!([
|
||||
{ "type": "thinking", "thinking": "hmm", "signature": "sig123" },
|
||||
{ "type": "redacted_thinking", "data": "b64data" },
|
||||
{
|
||||
"type": "reasoning",
|
||||
"id": "rs_1",
|
||||
"summary": [{ "type": "summary_text", "text": "thinking about it" }],
|
||||
"encrypted_content": "enc123",
|
||||
},
|
||||
{
|
||||
"type": "reasoning",
|
||||
"id": "rs_2",
|
||||
"summary": [],
|
||||
},
|
||||
]);
|
||||
|
||||
let blocks: Vec<ThinkingBlock> = serde_json::from_value(json.clone()).unwrap();
|
||||
|
||||
let yaml = serde_yaml::to_string(&blocks).unwrap();
|
||||
assert!(!yaml.contains("encrypted_content: null"));
|
||||
|
||||
let restored: Vec<ThinkingBlock> = serde_yaml::from_str(&yaml).unwrap();
|
||||
assert_eq!(serde_json::to_value(&restored).unwrap(), json);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user