MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / safe_write_output_is_valid_json

Function safe_write_output_is_valid_json

src/agents/mod.rs:2341–2358  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2339
2340 #[test]
2341 fn safe_write_output_is_valid_json() {
2342 // Verify the written file is always parseable JSON (round-trip).
2343 let dir = tmpdir();
2344 let path = dir.path().join("roundtrip.json");
2345 let value = serde_json::json!({
2346 "unicode": "héllo wörld 🦀",
2347 "nested": {"deep": {"array": [1, null, true, "str"]}},
2348 "empty_obj": {},
2349 "empty_arr": []
2350 });
2351
2352 safe_write_json_file(&path, &value, None).unwrap();
2353
2354 let raw = fs::read_to_string(&path).unwrap();
2355 let reparsed: serde_json::Value =
2356 serde_json::from_str(&raw).expect("written file must be valid JSON");
2357 assert_eq!(reparsed, value);
2358 }
2359}
2360
2361#[cfg(test)]

Callers

nothing calls this directly

Calls 2

tmpdirFunction · 0.85
safe_write_json_fileFunction · 0.85

Tested by

no test coverage detected