mirror of
https://github.com/openai/codex.git
synced 2026-10-30 19:18:49 +00:00
codex: sort guardian action json (#13593)
This commit is contained in:
@@ -664,12 +664,14 @@ fn truncate_guardian_action_value(value: Value) -> Value {
|
||||
.map(truncate_guardian_action_value)
|
||||
.collect::<Vec<_>>(),
|
||||
),
|
||||
Value::Object(values) => Value::Object(
|
||||
values
|
||||
Value::Object(values) => {
|
||||
let mut entries = values
|
||||
.into_iter()
|
||||
.map(|(key, value)| (key, truncate_guardian_action_value(value)))
|
||||
.collect(),
|
||||
),
|
||||
.collect::<Vec<_>>();
|
||||
entries.sort_by(|(left, _), (right, _)| left.cmp(right));
|
||||
Value::Object(entries.into_iter().collect())
|
||||
}
|
||||
other => other,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,8 +169,28 @@ fn format_guardian_action_pretty_truncates_large_string_fields() {
|
||||
.as_str()
|
||||
.expect("test patch should serialize as a string");
|
||||
|
||||
let change_count_index = rendered
|
||||
.find("\"change_count\"")
|
||||
.expect("rendered json should contain change_count");
|
||||
let cwd_index = rendered
|
||||
.find("\"cwd\"")
|
||||
.expect("rendered json should contain cwd");
|
||||
let files_index = rendered
|
||||
.find("\"files\"")
|
||||
.expect("rendered json should contain files");
|
||||
let patch_index = rendered
|
||||
.find("\"patch\"")
|
||||
.expect("rendered json should contain patch");
|
||||
let tool_index = rendered
|
||||
.find("\"tool\"")
|
||||
.expect("rendered json should contain tool");
|
||||
|
||||
assert!(rendered.contains("\"tool\": \"apply_patch\""));
|
||||
assert!(rendered.len() < original_patch.len());
|
||||
assert!(change_count_index < cwd_index);
|
||||
assert!(cwd_index < files_index);
|
||||
assert!(files_index < patch_index);
|
||||
assert!(patch_index < tool_index);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user