Skip to content

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

test(schemas): add initial test file for schema commands

Steven Enamakel050eb05d3288
diff --git a/crates/openhuman-core/src/commands/schemas_tests.rs b/crates/openhuman-core/src/commands/schemas_tests.rs
new file mode 100644
index 0000000000..d0e1decb9f
--- /dev/null
+++ b/crates/openhuman-core/src/commands/schemas_tests.rs
@@ -0,0 +1,48 @@
+use super::*;
+
+#[test]
+fn controller_schema_inventory_is_stable() {
+ let schemas = all_controller_schemas();
+ let functions: Vec<_> = schemas.iter().map(|schema| schema.function).collect();
+ assert_eq!(functions, vec!["list"]);
+ assert_eq!(schemas.len(), all_registered_controllers().len());
+ for schema in &schemas {
+ assert_eq!(schema.namespace, "commands");
+ }
+}
+
+#[test]
+fn list_schema_has_no_required_inputs() {
+ let schema = schemas("list");
+ assert!(schema.inputs.is_empty());
+ assert_eq!(schema.outputs.len(), 1);
+ assert_eq!(schema.outputs[0].name, "commands");
+}
+
+#[test]
+fn unknown_function_falls_back_to_an_error_schema() {
+ let schema = schemas("does_not_exist");
+ assert_eq!(schema.function, "unknown");
+ assert_eq!(schema.outputs[0].name, "error");
+}
+
+#[tokio::test]
+async fn handle_list_returns_every_builtin() {
+ use serde_json::Map;
+
+ let value = handle_list(Map::new()).await.expect("handler must not fail");
+ // Bare (no logs) or wrapped ({"result": ...}) — read through both.
+ let commands = value
+ .get("result")
+ .unwrap_or(&value)
+ .get("commands")
+ .and_then(|v| v.as_array())
+ .expect("commands array");
+ let ids: Vec<&str> = commands
+ .iter()
+ .filter_map(|c| c.get("id").and_then(|v| v.as_str()))
+ .collect();
+ for expected in ["new", "clear", "plan", "build", "goal", "todo", "stop"] {
+ assert!(ids.contains(&expected), "missing builtin {expected}: {ids:?}");
+ }
+}