Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

refactor(tests): simplify schema_string_values logic

Steven Enamakela209200a323e
diff --git a/crates/openhuman-core/src/threads/wire_schema_tests.rs b/crates/openhuman-core/src/threads/wire_schema_tests.rs
index ddfba0471d..1d16fb86e0 100644
--- a/crates/openhuman-core/src/threads/wire_schema_tests.rs
+++ b/crates/openhuman-core/src/threads/wire_schema_tests.rs
@@ -13,28 +13,26 @@ fn resolve_schema<'a>(
fn schema_string_values(root: &serde_json::Value, schema: &serde_json::Value) -> Vec<String> {
let schema = resolve_schema(root, schema);
- let mut values: Vec<String> = if let Some(values) = schema
- .get("enum")
- .and_then(serde_json::Value::as_array)
- {
- values
- .iter()
- .map(|value| value.as_str().expect("string enum value").to_owned())
- .collect()
- } else {
- schema
- .get("oneOf")
- .and_then(serde_json::Value::as_array)
- .expect("string enum or oneOf schema")
- .iter()
- .map(|variant| {
- variant["const"]
- .as_str()
- .expect("string oneOf const")
- .to_owned()
- })
- .collect()
- };
+ let mut values: Vec<String> =
+ if let Some(values) = schema.get("enum").and_then(serde_json::Value::as_array) {
+ values
+ .iter()
+ .map(|value| value.as_str().expect("string enum value").to_owned())
+ .collect()
+ } else {
+ schema
+ .get("oneOf")
+ .and_then(serde_json::Value::as_array)
+ .expect("string enum or oneOf schema")
+ .iter()
+ .map(|variant| {
+ variant["const"]
+ .as_str()
+ .expect("string oneOf const")
+ .to_owned()
+ })
+ .collect()
+ };
values.sort();
values
}