The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
test(channels): split provider route tests into a separate module
Steven Enamakelba30892bd690
diff --git a/crates/openhuman-core/src/channels/routes.rs b/crates/openhuman-core/src/channels/routes.rsindex c1dc6a1407..79d6e265e2 100644--- a/crates/openhuman-core/src/channels/routes.rs+++ b/crates/openhuman-core/src/channels/routes.rs@@ -256,3 +256,7 @@ pub(crate) async fn handle_runtime_command_if_needed(#[cfg(test)]#[path = "routes_tests.rs"]mod tests;++#[cfg(test)]+#[path = "routes_provider_tests.rs"]+mod provider_tests;diff --git a/crates/openhuman-core/src/channels/routes_provider_tests.rs b/crates/openhuman-core/src/channels/routes_provider_tests.rsnew file mode 100644index 0000000000..b02baaf73f--- /dev/null+++ b/crates/openhuman-core/src/channels/routes_provider_tests.rs@@ -0,0 +1,68 @@+use super::tests::{runtime_context, RecordingChannel};+use super::*;+use crate::channels::context::conversation_history_key;+use crate::channels::{Channel, SendMessage};+use std::path::PathBuf;+use std::sync::Arc;+use tinychannels_bus::ChannelMessage;++#[tokio::test]+async fn handle_runtime_command_routes_configured_provider_slug_and_alias() {+ use crate::config::schema::{AuthStyle, CloudProviderCreds};++ let mut ctx = runtime_context(PathBuf::from("/tmp"));+ let config = crate::config::Config {+ cloud_providers: vec![+ CloudProviderCreds {+ id: "p_custom_route_123".into(),+ slug: "custom-route".into(),+ label: "Human Friendly Name".into(),+ endpoint: "https://provider.example.test/v1".into(),+ auth_style: AuthStyle::Bearer,+ default_model: None,+ },+ CloudProviderCreds {+ id: "p_managed_123".into(),+ slug: "openhuman".into(),+ label: "Managed Backend".into(),+ endpoint: "https://api.openhuman.ai/v1".into(),+ auth_style: AuthStyle::OpenhumanJwt,+ default_model: None,+ },+ ],+ ..crate::config::Config::default()+ };+ ctx.config = Some(Arc::new(config));+ let channel_impl = Arc::new(RecordingChannel::default());+ let channel: Arc<dyn Channel> = channel_impl.clone();+ let key = "telegram_alice_room";++ for requested in ["custom-route", "backend"] {+ let msg = ChannelMessage {+ id: requested.into(),+ sender: "alice".into(),+ reply_target: "room".into(),+ content: format!("/models {requested}"),+ channel: "telegram".into(),+ timestamp: 0,+ thread_ts: None,+ sender_name: None,+ };+ assert!(+ handle_runtime_command_if_needed(+ &ctx,+ &msg,+ Some(&channel),+ &conversation_history_key(&msg),+ )+ .await+ );+ }++ assert_eq!(get_route_selection(&ctx, key).provider, "openhuman");+ let sent = channel_impl.sent.lock().unwrap();+ assert_eq!(sent.len(), 1, "the configured slug should be accepted");+ assert!(sent[0]+ .content+ .contains("Provider switched to `custom-route`"));+}diff --git a/crates/openhuman-core/src/channels/routes_tests.rs b/crates/openhuman-core/src/channels/routes_tests.rsindex 167f7f391a..969b4cf0dd 100644--- a/crates/openhuman-core/src/channels/routes_tests.rs+++ b/crates/openhuman-core/src/channels/routes_tests.rs@@ -38,7 +38,7 @@ impl Tool for DummyTool {}#[derive(Default)]-struct RecordingChannel {+pub(super) struct RecordingChannel {sent: Mutex<Vec<SendMessage>>,}@@ -58,7 +58,7 @@ impl Channel for RecordingChannel {}}-fn runtime_context(workspace_dir: PathBuf) -> ChannelRuntimeContext {+pub(super) fn runtime_context(workspace_dir: PathBuf) -> ChannelRuntimeContext {let model: Arc<dyn tinyinference_llm::model::ChatModel<()>> =Arc::new(tinyagents_harness::testkit::ScriptedModel::replies(vec!["ok",@@ -337,67 +337,6 @@ async fn load_cached_model_preview_returns_empty_when_cache_json_is_invalid() {assert!(response.contains("No cached model list found for `openai`"));}-#[tokio::test]-async fn handle_runtime_command_routes_configured_provider_slug_and_alias() {- use crate::config::schema::{AuthStyle, CloudProviderCreds};-- let mut ctx = runtime_context(PathBuf::from("/tmp"));- let config = crate::config::Config {- cloud_providers: vec![- CloudProviderCreds {- id: "p_custom_route_123".into(),- slug: "custom-route".into(),- label: "Human Friendly Name".into(),- endpoint: "https://provider.example.test/v1".into(),- auth_style: AuthStyle::Bearer,- default_model: None,- },- CloudProviderCreds {- id: "p_managed_123".into(),- slug: "openhuman".into(),- label: "Managed Backend".into(),- endpoint: "https://api.openhuman.ai/v1".into(),- auth_style: AuthStyle::OpenhumanJwt,- default_model: None,- },- ],- ..crate::config::Config::default()- };- ctx.config = Some(Arc::new(config));- let channel_impl = Arc::new(RecordingChannel::default());- let channel: Arc<dyn Channel> = channel_impl.clone();- let key = "telegram_alice_room";-- for requested in ["custom-route", "backend"] {- let msg = ChannelMessage {- id: requested.into(),- sender: "alice".into(),- reply_target: "room".into(),- content: format!("/models {requested}"),- channel: "telegram".into(),- timestamp: 0,- thread_ts: None,- sender_name: None,- };- assert!(- handle_runtime_command_if_needed(- &ctx,- &msg,- Some(&channel),- &conversation_history_key(&msg),- )- .await- );- }-- assert_eq!(get_route_selection(&ctx, key).provider, "openhuman");- let sent = channel_impl.sent.lock().unwrap();- assert_eq!(sent.len(), 1, "the configured slug should be accepted");- assert!(sent[0]- .content- .contains("Provider switched to `custom-route`"));-}-#[tokio::test]async fn handle_runtime_command_unknown_provider_sends_helpful_error() {let ctx = runtime_context(PathBuf::from("/tmp"));