Skip to content

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

chore(tests): add schema tests for command center and session db

Steven Enamakel58de962e21e4
diff --git a/crates/openhuman-core/src/agent/orchestration/command_center/schemas_tests.rs b/crates/openhuman-core/src/agent/orchestration/command_center/schemas_tests.rs
index f2b864ec00..a15dc65afa 100644
--- a/crates/openhuman-core/src/agent/orchestration/command_center/schemas_tests.rs
+++ b/crates/openhuman-core/src/agent/orchestration/command_center/schemas_tests.rs
@@ -60,7 +60,12 @@ fn params(value: Value) -> Map<String, Value> {
async fn listing_work_on_an_empty_ledger_answers() {
let v = with_scratch_workspace(|| handle_agent_work_list(params(serde_json::json!({ "limit": 5 }))))
.await
- .expect("an empty ledger lists as an empty view");eprintln!("DBG-WORK {v}");
+ .expect("an empty ledger lists as an empty view");
+ assert_eq!(v["total"], 0, "{v}");
+ assert!(
+ v["groups"].as_array().unwrap().iter().all(|g| g["rows"] == serde_json::json!([])),
+ "{v}"
+ );
}
#[tokio::test]
diff --git a/crates/openhuman-core/src/agent/session_db/schemas_tests.rs b/crates/openhuman-core/src/agent/session_db/schemas_tests.rs
index 4371b86d2b..1fa753d947 100644
--- a/crates/openhuman-core/src/agent/session_db/schemas_tests.rs
+++ b/crates/openhuman-core/src/agent/session_db/schemas_tests.rs
@@ -106,7 +106,8 @@ async fn listing_an_empty_ledger_returns_no_runs() {
.await
.expect("list answers on an empty ledger");
let text = value.to_string();
- eprintln!("DBG-LIST {value}");assert!(text.contains("runs") || text.contains("items"), "{text}");
+ assert_eq!(value["runs"], serde_json::json!([]), "{text}");
+ assert_eq!(value["count"], 0, "{text}");
}
#[tokio::test]
@@ -126,7 +127,7 @@ async fn getting_an_unknown_run_answers_null() {
})
.await
.expect("get answers for an unknown id");
- eprintln!("DBG-GET {value}");assert!(value.to_string().contains("null"), "{value}");
+ assert!(value["run"].is_null(), "{value}");
}
#[tokio::test]
@@ -139,12 +140,13 @@ async fn getting_a_run_requires_an_id() {
#[tokio::test]
async fn events_of_an_unknown_run_are_empty() {
- with_scratch_workspace(|| {
+ let value = with_scratch_workspace(|| {
handle_run_ledger_events(params(serde_json::json!({ "runId": "no-such-run" })))
})
.await
- .map(|v| eprintln!("DBG-EV {v}"))
.expect("events answer for an unknown run");
+ assert_eq!(value["events"], serde_json::json!([]), "{value}");
+ assert_eq!(value["count"], 0, "{value}");
}
#[tokio::test]