Skip to content

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

test(channels): update test context binding with config

Steven Enamakel68922aa48223
diff --git a/crates/openhuman-core/src/channels/routes_tests.rs b/crates/openhuman-core/src/channels/routes_tests.rs
index 298b69d687..2f0de9968e 100644
--- a/crates/openhuman-core/src/channels/routes_tests.rs
+++ b/crates/openhuman-core/src/channels/routes_tests.rs
@@ -78,7 +78,8 @@ async fn handle_linked_runtime_command(
use tinychannels_bus::module_remote::RemoteSessionScope;
ctx.channels_by_name = linked.channels();
- let _core = crate::channels::runtime::test_support::bind_test_core_context(ctx);
+ let _core =
+ crate::channels::runtime::test_support::bind_test_core_context(ctx, linked.config());
let prepared = crate::modules::channel_controller::prepare_inbound(
&crate::channels::context::module_client(ctx).await,
PrepareChannelInboundRequest {
@@ -101,7 +102,7 @@ async fn handle_linked_runtime_command(
};
handle_runtime_command_with_reset(
ctx,
- msg,
+ &prepared.message,
target_channel,
&prepared.history_key,
Some(scope),
diff --git a/crates/openhuman-core/src/channels/runtime/test_support.rs b/crates/openhuman-core/src/channels/runtime/test_support.rs
index 6438d8bf02..65b5e60218 100644
--- a/crates/openhuman-core/src/channels/runtime/test_support.rs
+++ b/crates/openhuman-core/src/channels/runtime/test_support.rs
@@ -137,6 +137,7 @@ pub(crate) struct LinkedTelegramRuntime {
_storage: crate::channels::module_fixture::MemoryStorageGuard,
_workspace: tempfile::TempDir,
server: MockServer,
+ config: crate::config::Config,
runtime: crate::channels::runtime::ModuleRuntimeTestGuard,
}
@@ -147,6 +148,10 @@ impl LinkedTelegramRuntime {
self.runtime.channels()
}
+ pub(crate) fn config(&self) -> &crate::config::Config {
+ &self.config
+ }
+
pub(crate) async fn provider_request_paths(&self) -> Vec<String> {
self.server
.received_requests()
@@ -185,6 +190,14 @@ pub(crate) async fn linked_telegram_runtime() -> LinkedTelegramRuntime {
})))
.mount(&server)
.await;
+ Mock::given(method("POST"))
+ .and(path("/bottoken/setMessageReaction"))
+ .respond_with(ResponseTemplate::new(200).set_body_json(serde_json::json!({
+ "ok": true,
+ "result": true
+ })))
+ .mount(&server)
+ .await;
Mock::given(method("POST"))
.and(path("/bottoken/sendMessage"))
.respond_with(ResponseTemplate::new(200).set_body_json(serde_json::json!({
@@ -236,6 +249,7 @@ pub(crate) async fn linked_telegram_runtime() -> LinkedTelegramRuntime {
_storage: storage,
_workspace: workspace,
server,
+ config,
runtime,
}
}
@@ -244,14 +258,24 @@ pub(crate) async fn linked_telegram_runtime() -> LinkedTelegramRuntime {
/// clear durable channel history exercise the host reset path.
pub(crate) fn bind_test_core_context(
context: &mut crate::channels::context::ChannelRuntimeContext,
+ base_config: &crate::config::Config,
) -> Arc<crate::core::runtime::CoreContext> {
use crate::core::runtime::{ContextOverlay, CoreContext, DomainSet};
let workspace = context.workspace_dir.as_ref().clone();
- let mut config = crate::config::Config::default();
+ let mut config = base_config.clone();
config.workspace_dir = workspace.clone();
config.action_dir = workspace.clone();
config.config_path = workspace.join("config.toml");
+ config.cloud_providers = vec![crate::config::schema::CloudProviderCreds {
+ id: "p_openai_channel_test".into(),
+ slug: "openai".into(),
+ label: "Channel test provider".into(),
+ endpoint: "http://127.0.0.1:9/v1".into(),
+ default_model: Some("channel-test-model".into()),
+ ..Default::default()
+ }];
+ context.config = Some(Arc::new(config.clone()));
let core = CoreContext::for_test(DomainSet::none(), Some(workspace)).derive_with(
ContextOverlay::new(config, DomainSet::full(), Default::default())
.profile("channel-handle-test"),
diff --git a/crates/openhuman-core/src/channels/tests/runtime_tool_calls.rs b/crates/openhuman-core/src/channels/tests/runtime_tool_calls.rs
index e1fbeb23f5..a4633e639b 100644
--- a/crates/openhuman-core/src/channels/tests/runtime_tool_calls.rs
+++ b/crates/openhuman-core/src/channels/tests/runtime_tool_calls.rs
@@ -130,7 +130,10 @@ async fn process_channel_message_handles_models_command_without_llm_call() {
config: None,
core: None,
};
- let _core = crate::channels::runtime::test_support::bind_test_core_context(&mut runtime_ctx);
+ let _core = crate::channels::runtime::test_support::bind_test_core_context(
+ &mut runtime_ctx,
+ _linked.config(),
+ );
let runtime_ctx = Arc::new(runtime_ctx);
let cmd_msg = traits::ChannelMessage {