Skip to content

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

test: add unit tests for ops, tokenjuice, memory, and sandbox

Steven Enamakel3cea4181fb8a
diff --git a/crates/openhuman-core/src/commands/ops_tests.rs b/crates/openhuman-core/src/commands/ops_tests.rs
index 920be77587..6723dbd107 100644
--- a/crates/openhuman-core/src/commands/ops_tests.rs
+++ b/crates/openhuman-core/src/commands/ops_tests.rs
@@ -65,7 +65,7 @@ async fn commands_list_always_includes_every_builtin_even_if_catalogs_fail() {
// end (no config override) — the important assertion is that whatever
// they do, every builtin is still present and the call itself never
// errors.
- let outcome = commands_list(DispatchCtx::process_default()).await.expect("commands_list must not fail");
+ let outcome = commands_list(&DispatchCtx::process_default()).await.expect("commands_list must not fail");
let ids: Vec<&str> = outcome
.value
.commands
diff --git a/crates/openhuman-core/src/inference/tokenjuice/schemas_tests.rs b/crates/openhuman-core/src/inference/tokenjuice/schemas_tests.rs
index e34e2192a6..ba7a0a2728 100644
--- a/crates/openhuman-core/src/inference/tokenjuice/schemas_tests.rs
+++ b/crates/openhuman-core/src/inference/tokenjuice/schemas_tests.rs
@@ -179,7 +179,7 @@ async fn every_tokenjuice_method_answers_component_disabled_when_juice_is_off()
let mut set = crate::core::runtime::ComponentSet::all();
set.juice = false;
let ctx = crate::core::runtime::context::CoreContext::for_test_with_components(set);
- let handlers: [fn(Map<String, Value>) -> ControllerFuture; 8] = [
+ let handlers: [fn(DispatchCtx, Map<String, Value>) -> ControllerFuture; 8] = [
handle_detect,
handle_compress,
handle_cache_stats,
@@ -189,9 +189,10 @@ async fn every_tokenjuice_method_answers_component_disabled_when_juice_is_off()
handle_savings_stats,
handle_savings_reset,
];
+ let dispatch = DispatchCtx::new(ctx.clone());
crate::core::runtime::context::CoreContext::scope(ctx, async {
for handler in handlers {
- let err = handler(Map::new()).await.unwrap_err();
+ let err = handler(dispatch.clone(), Map::new()).await.unwrap_err();
let decoded = crate::core::StructuredRpcError::decode(&err).expect("typed error");
assert_eq!(decoded.message, "COMPONENT_DISABLED:juice");
}
diff --git a/crates/openhuman-core/src/memory/convert_tests.rs b/crates/openhuman-core/src/memory/convert_tests.rs
index ca813bed51..bc621c0fbf 100644
--- a/crates/openhuman-core/src/memory/convert_tests.rs
+++ b/crates/openhuman-core/src/memory/convert_tests.rs
@@ -300,6 +300,7 @@ async fn brain_ingest_files_a_pdf_by_path() {
let view = ingest(
&config,
+ &crate::memory::scope::MemoryIdentity::root().resolve(&config),
BrainIngestParams {
path: Some(path.display().to_string()),
text: None,
diff --git a/crates/openhuman-core/src/sandbox/schemas_tests.rs b/crates/openhuman-core/src/sandbox/schemas_tests.rs
index dee9cca673..52f9f7b352 100644
--- a/crates/openhuman-core/src/sandbox/schemas_tests.rs
+++ b/crates/openhuman-core/src/sandbox/schemas_tests.rs
@@ -209,15 +209,16 @@ async fn every_sandbox_method_answers_component_disabled_when_sandbox_is_off() {
let mut set = crate::core::runtime::ComponentSet::all();
set.sandbox = false;
let ctx = crate::core::runtime::context::CoreContext::for_test_with_components(set);
- let handlers: [fn(Map<String, Value>) -> ControllerFuture; 4] = [
+ let handlers: [fn(DispatchCtx, Map<String, Value>) -> ControllerFuture; 4] = [
handle_status,
handle_resolve_policy,
handle_cleanup_orphans,
handle_validate_policy,
];
+ let dispatch = DispatchCtx::new(ctx.clone());
crate::core::runtime::context::CoreContext::scope(ctx, async {
for handler in handlers {
- let err = handler(Map::new()).await.unwrap_err();
+ let err = handler(dispatch.clone(), Map::new()).await.unwrap_err();
let decoded = crate::core::StructuredRpcError::decode(&err).expect("typed error");
assert_eq!(decoded.message, "COMPONENT_DISABLED:sandbox");
}