Skip to content

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

test: add integration and unit tests across core modules

Steven Enamakel6cebf61bc93d
diff --git a/crates/openhuman-core/src/channels/tests/telegram_integration.rs b/crates/openhuman-core/src/channels/tests/telegram_integration.rs
index 7ab7c5acdf..684dd48639 100644
--- a/crates/openhuman-core/src/channels/tests/telegram_integration.rs
+++ b/crates/openhuman-core/src/channels/tests/telegram_integration.rs
@@ -102,6 +102,7 @@ fn make_test_context(
multimodal: crate::config::MultimodalConfig::default(),
multimodal_files: crate::config::MultimodalFileConfig::default(),
config: None,
+ core: None,
})
}
diff --git a/crates/openhuman-core/src/core/events_tests.rs b/crates/openhuman-core/src/core/events_tests.rs
index 0298859e50..a9de36216e 100644
--- a/crates/openhuman-core/src/core/events_tests.rs
+++ b/crates/openhuman-core/src/core/events_tests.rs
@@ -343,6 +343,7 @@ fn all_variants_have_correct_domain() {
toolkit: "gmail".into(),
connection_id: "conn-1".into(),
connect_url: "https://backend.composio.dev/connect/abc".into(),
+ tenant: None,
},
"composio",
),
@@ -366,6 +367,7 @@ fn all_variants_have_correct_domain() {
DomainEvent::ComposioConfigChanged {
mode: "direct".into(),
api_key_set: true,
+ tenant: None,
},
"composio",
),
diff --git a/crates/openhuman-core/src/flows/bus_tests.rs b/crates/openhuman-core/src/flows/bus_tests.rs
index 18d324297e..f2e01d402d 100644
--- a/crates/openhuman-core/src/flows/bus_tests.rs
+++ b/crates/openhuman-core/src/flows/bus_tests.rs
@@ -124,7 +124,9 @@ async fn a_trigger_handled_as_an_agent_uses_the_agent_config() {
};
let subscriber = FlowTriggerSubscriber::new(std::sync::Arc::new(registered));
assert_eq!(
- subscriber.config_for_scope().workspace_dir,
+ subscriber
+ .config_for_scope(&crate::core::runtime::DispatchCtx::unbound())
+ .workspace_dir,
std::path::PathBuf::from("/tmp/flows-trigger-registered"),
"outside an agent the registered config is used"
);
@@ -136,10 +138,10 @@ async fn a_trigger_handled_as_an_agent_uses_the_agent_config() {
ContextOverlay::new(agent_config, DomainSet::full(), Default::default())
.session_agent("flows-trigger-agent"),
);
- let seen = CoreContext::scope(agent, async {
- subscriber.config_for_scope().workspace_dir.clone()
- })
- .await;
+ let seen = subscriber
+ .config_for_scope(&crate::core::runtime::DispatchCtx::new(agent))
+ .workspace_dir
+ .clone();
assert_eq!(seen, std::path::PathBuf::from("/tmp/flows-trigger-agent"));
}
diff --git a/crates/openhuman-core/src/integrations/composio/bus_tests.rs b/crates/openhuman-core/src/integrations/composio/bus_tests.rs
index e157904b5c..be380d1a83 100644
--- a/crates/openhuman-core/src/integrations/composio/bus_tests.rs
+++ b/crates/openhuman-core/src/integrations/composio/bus_tests.rs
@@ -211,6 +211,7 @@ async fn handles_connection_created_event_without_panic() {
toolkit: "gmail".into(),
connection_id: "conn-1".into(),
connect_url: "https://composio.example/connect/abc".into(),
+ tenant: None,
})
.await;
@@ -254,6 +255,7 @@ async fn trigger_subscriber_ignores_other_composio_event_variants() {
toolkit: "gmail".into(),
connection_id: "c-1".into(),
connect_url: "url".into(),
+ tenant: None,
})
.await;
}
@@ -300,6 +302,7 @@ async fn connection_subscriber_skips_when_not_signed_in() {
toolkit: "__no_such_provider_toolkit__".into(),
connection_id: "c-1".into(),
connect_url: "url".into(),
+ tenant: None,
})
.await;
@@ -320,11 +323,13 @@ async fn config_changed_subscriber_invalidates_cache() {
sub.handle(&DomainEvent::ComposioConfigChanged {
mode: "direct".into(),
api_key_set: true,
+ tenant: None,
})
.await;
sub.handle(&DomainEvent::ComposioConfigChanged {
mode: "backend".into(),
api_key_set: false,
+ tenant: None,
})
.await;
}
@@ -336,6 +341,7 @@ async fn config_changed_subscriber_ignores_unrelated_variants() {
toolkit: "gmail".into(),
connection_id: "c-1".into(),
connect_url: "url".into(),
+ tenant: None,
})
.await;
// No panic = pass.
diff --git a/crates/openhuman-core/src/integrations/composio/ops_direct_mode_and_error_classification_tests.rs b/crates/openhuman-core/src/integrations/composio/ops_direct_mode_and_error_classification_tests.rs
index a47205e25a..9dfbe44a72 100644
--- a/crates/openhuman-core/src/integrations/composio/ops_direct_mode_and_error_classification_tests.rs
+++ b/crates/openhuman-core/src/integrations/composio/ops_direct_mode_and_error_classification_tests.rs
@@ -177,7 +177,7 @@ async fn composio_authorize_routes_through_direct_mode() {
// "composio unavailable / no backend session" instead.
let tmp = tempfile::tempdir().unwrap();
let config = direct_mode_config(&tmp);
- let err = composio_authorize(&config, "gmail", None)
+ let err = composio_authorize(&crate::core::runtime::DispatchCtx::host_default(), &config, "gmail", None)
.await
.unwrap_err();
assert!(
diff --git a/crates/openhuman-core/src/integrations/composio/ops_no_session_and_cache_tests.rs b/crates/openhuman-core/src/integrations/composio/ops_no_session_and_cache_tests.rs
index 58313179b6..803cb310ed 100644
--- a/crates/openhuman-core/src/integrations/composio/ops_no_session_and_cache_tests.rs
+++ b/crates/openhuman-core/src/integrations/composio/ops_no_session_and_cache_tests.rs
@@ -76,7 +76,7 @@ async fn composio_authorize_errors_without_session() {
let _serialised = module_guard().await;
let tmp = tempfile::tempdir().unwrap();
let config = test_config(&tmp);
- let err = composio_authorize(&config, "gmail", None)
+ let err = composio_authorize(&crate::core::runtime::DispatchCtx::host_default(), &config, "gmail", None)
.await
.unwrap_err();
// Backend mode (default) without a session — the mode-aware factory
@@ -348,7 +348,7 @@ async fn composio_authorize_clears_pending_meta_connection_before_handoff() {
let base = start_mock_backend(app).await;
let tmp = tempfile::tempdir().unwrap();
let config = config_with_backend(&tmp, base);
- let outcome = composio_authorize(&config, "instagram", None)
+ let outcome = composio_authorize(&crate::core::runtime::DispatchCtx::host_default(), &config, "instagram", None)
.await
.unwrap();
assert_eq!(outcome.value.connection_id, "c-new");
@@ -370,7 +370,7 @@ async fn composio_authorize_via_mock_publishes_event_and_returns_url() {
let base = start_mock_backend(app).await;
let tmp = tempfile::tempdir().unwrap();
let config = config_with_backend(&tmp, base);
- let outcome = composio_authorize(&config, "gmail", None).await.unwrap();
+ let outcome = composio_authorize(&crate::core::runtime::DispatchCtx::host_default(), &config, "gmail", None).await.unwrap();
assert_eq!(outcome.value.connect_url, "https://x");
assert_eq!(outcome.value.connection_id, "c1");
}
diff --git a/crates/openhuman-core/src/integrations/task_sources/bus_tests.rs b/crates/openhuman-core/src/integrations/task_sources/bus_tests.rs
index e08d7b89e1..1ef59090ff 100644
--- a/crates/openhuman-core/src/integrations/task_sources/bus_tests.rs
+++ b/crates/openhuman-core/src/integrations/task_sources/bus_tests.rs
@@ -74,6 +74,7 @@ async fn a_connection_event_is_handled_per_scope() {
toolkit: toolkit.to_string(),
connection_id: "conn-1".to_string(),
connect_url: String::new(),
+ tenant: None,
};
// Not a task-source toolkit.
TaskSourcesConnectionSubscriber
diff --git a/crates/openhuman-core/src/search/bus_tests.rs b/crates/openhuman-core/src/search/bus_tests.rs
index b5c1926100..b0f1cd7689 100644
--- a/crates/openhuman-core/src/search/bus_tests.rs
+++ b/crates/openhuman-core/src/search/bus_tests.rs
@@ -11,6 +11,7 @@ fn subscriber_identity_and_domain() {
fn credential_changed_is_an_auth_event() {
let event = DomainEvent::CredentialChanged {
kind: "session".into(),
+ tenant: None,
};
assert_eq!(event.domain(), "auth");
}
@@ -33,6 +34,7 @@ async fn refresh_is_a_no_op_while_the_module_is_not_loaded() {
CredentialRefreshSubscriber
.handle(&DomainEvent::CredentialChanged {
kind: "cleared".into(),
+ tenant: None,
})
.await;
}
diff --git a/crates/openhuman-core/src/storage/agents_tests.rs b/crates/openhuman-core/src/storage/agents_tests.rs
index f48e8af462..76da4da77b 100644
--- a/crates/openhuman-core/src/storage/agents_tests.rs
+++ b/crates/openhuman-core/src/storage/agents_tests.rs
@@ -132,24 +132,24 @@ async fn without_a_backend_only_the_local_scope_runs() {
return;
}
let agent = live_agent("agents-test-unvisited");
- let runs = for_each_scope("test", || async {
+ let runs = for_each_scope("test", |_| async {
CoreContext::current().and_then(|c| c.session_agent().map(str::to_string))
})
.await;
assert_eq!(runs.len(), 1);
assert_eq!(runs[0].0, None);
- assert!(for_each_agent("test", || async {}).await.is_empty());
+ assert!(for_each_agent("test", |_| async {}).await.is_empty());
assert_eq!(
- find_owner("test", || async { Ok(false) }).await,
+ find_owner("test", |_| async { Ok(false) }).await,
Ok(None),
"nothing anywhere"
);
assert_eq!(
- find_owner("test", || async { Ok(true) }).await,
+ find_owner("test", |_| async { Ok(true) }).await,
Ok(Some(None))
);
assert!(
- find_owner("test", || async { Err("down".to_string()) })
+ find_owner("test", |_| async { Err("down".to_string()) })
.await
.is_err(),
"a failed lookup with no match fails closed"
@@ -169,7 +169,7 @@ async fn without_a_backend_the_live_pass_runs_only_local() {
return;
}
let agent = live_agent("agents-test-live-pass");
- let runs = for_each_live_scope("test", || async { 1 }).await;
+ let runs = for_each_live_scope("test", |_| async { 1 }).await;
assert_eq!(runs, vec![(None, 1)]);
AgentContextRegistry::deregister("agents-test-live-pass", &agent);
}
@@ -199,7 +199,7 @@ async fn the_local_pass_runs_outside_the_callers_agent() {
}
let agent = live_agent("agents-test-caller");
let seen = CoreContext::scope(Arc::clone(&agent), async {
- for_each_scope("test", || async {
+ for_each_scope("test", |_| async {
CoreContext::current().and_then(|c| c.session_agent().map(str::to_string))
})
.await