Skip to content

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

test(core): add tests for builder and config loading

Steven Enamakelfb41a67c2280
diff --git a/crates/openhuman-core/src/agent/session_host/builder/builder_tests_model_source_tests.rs b/crates/openhuman-core/src/agent/session_host/builder/builder_tests_model_source_tests.rs
index 76792971e6..f721ce9a3e 100644
--- a/crates/openhuman-core/src/agent/session_host/builder/builder_tests_model_source_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/builder/builder_tests_model_source_tests.rs
@@ -1,13 +1,18 @@
+use super::*;
use std::sync::Arc;
#[test]
fn builder_requires_a_model_when_no_host_policy_is_installed() {
+ let tmp = tempfile::TempDir::new().unwrap();
+ let config = test_config(&tmp);
+ assert!(config.default_model.is_none());
let model: Arc<dyn tinyinference_llm::model::ChatModel<()>> =
Arc::new(tinyagents_harness::testkit::ScriptedModel::new(Vec::new()));
let error = crate::agent::SessionHostBuilder::new()
.chat_model(model)
.tools(Vec::new())
.tool_dispatcher(Box::new(tinytools_agent::dialect::XmlDialect))
+ .workspace_dir(config.workspace_dir)
.build()
.err()
.expect("a bare core builder needs an explicit model");
diff --git a/crates/openhuman-core/src/config/schema/load_managed_provider_tests.rs b/crates/openhuman-core/src/config/schema/load_managed_provider_tests.rs
index f03625a065..333c6199d7 100644
--- a/crates/openhuman-core/src/config/schema/load_managed_provider_tests.rs
+++ b/crates/openhuman-core/src/config/schema/load_managed_provider_tests.rs
@@ -6,22 +6,36 @@ use super::*;
#[tokio::test]
async fn a_brand_new_workspace_persists_and_reopens_generic_config() {
let tmp = tempfile::tempdir().unwrap();
+ crate::inference::registry::register_config_normalizer(
+ "fresh-install-test",
+ std::sync::Arc::new(|config| {
+ if !config.cloud_providers.is_empty() {
+ return false;
+ }
+ config.cloud_providers.push(crate::config::schema::CloudProviderCreds {
+ id: "fixture-provider-id".to_string(),
+ slug: "fixture-provider".to_string(),
+ label: "Fixture Provider".to_string(),
+ endpoint: "https://fixture.example/v1".to_string(),
+ auth_style: crate::config::schema::AuthStyle::Bearer,
+ default_model: None,
+ });
+ true
+ }),
+ );
let first = load_or_init_for_workspace(tmp.path()).await;
assert!(first.default_model.is_none());
- assert!(first
- .cloud_providers
- .iter()
- .all(|provider| provider.slug != "openhuman"));
+ assert_eq!(first.cloud_providers.len(), 1);
+ assert_eq!(first.cloud_providers[0].slug, "fixture-provider");
let first_text = tokio::fs::read_to_string(&first.config_path).await.unwrap();
assert!(first_text.contains("schema_version"));
+ assert!(first_text.contains("slug = \"fixture-provider\""));
let second = load_or_init_for_workspace(tmp.path()).await;
assert!(second.default_model.is_none());
- assert!(second
- .cloud_providers
- .iter()
- .all(|provider| provider.slug != "openhuman"));
+ assert_eq!(second.cloud_providers.len(), 1);
+ assert_eq!(second.cloud_providers[0].id, "fixture-provider-id");
}
#[tokio::test]