Skip to content

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

test(provider): split model catalog tests into dedicated modules

Steven Enamakel1734884f4dce
diff --git a/crates/openhuman-core/src/inference/embedding_host/mod_tests.rs b/crates/openhuman-core/src/inference/embedding_host/mod_tests.rs
index f1789cca70..675558199d 100644
--- a/crates/openhuman-core/src/inference/embedding_host/mod_tests.rs
+++ b/crates/openhuman-core/src/inference/embedding_host/mod_tests.rs
@@ -4,8 +4,8 @@
//! `#[path = "mod_tests.rs"] mod tests;` so `super::*` still resolves to the
//! `embeddings` module.
-use super::*;
use super::cloud::{DEFAULT_CLOUD_EMBEDDING_DIMENSIONS, DEFAULT_CLOUD_EMBEDDING_MODEL};
+use super::*;
// ── create_embedding_provider_with_credentials ───────────
diff --git a/crates/openhuman-core/src/inference/provider/mod.rs b/crates/openhuman-core/src/inference/provider/mod.rs
index a16edb47e3..d7bb5d464a 100644
--- a/crates/openhuman-core/src/inference/provider/mod.rs
+++ b/crates/openhuman-core/src/inference/provider/mod.rs
@@ -37,5 +37,5 @@ pub use factory::{
pub use openhuman_backend_model::PROVIDER_LABEL;
#[cfg(test)]
-#[path = "ops_tests.rs"]
-mod model_listing_tests;
+#[path = "model_listing_test_support.rs"]
+pub(crate) mod model_listing_test_support;
diff --git a/crates/openhuman-core/src/inference/provider/ops_tests.rs b/crates/openhuman-core/src/inference/provider/model_listing_test_support.rs
similarity index 83%
rename from crates/openhuman-core/src/inference/provider/ops_tests.rs
rename to crates/openhuman-core/src/inference/provider/model_listing_test_support.rs
index 8d4d99a9c1..9f166560a7 100644
--- a/crates/openhuman-core/src/inference/provider/ops_tests.rs
+++ b/crates/openhuman-core/src/inference/provider/model_listing_test_support.rs
@@ -1,13 +1,3 @@
-use super::factory::INFERENCE_BACKEND_ID;
-use super::http_error::{
- api_error, is_backend_auth_failure, is_backend_error_code_owned,
- should_report_provider_http_failure,
-};
-use super::models::{
- list_configured_models, list_configured_models_from_config, synthesize_local_runtime_entry,
-};
-use super::openhuman_backend_model::PROVIDER_LABEL;
-use super::*;
use crate::config::schema::cloud_providers::{AuthStyle, CloudProviderCreds};
use crate::config::Config;
use crate::security::credentials::AuthService;
@@ -27,12 +17,12 @@ use tempfile::TempDir;
use tinyinference_core::sanitize::{sanitize_api_error, MAX_API_ERROR_CHARS};
#[derive(Clone)]
-struct ModelProbeState {
- key_status: StatusCode,
- key_calls: Arc<AtomicUsize>,
- model_calls: Arc<AtomicUsize>,
- key_authorization: Arc<Mutex<Vec<Option<String>>>>,
- model_authorization: Arc<Mutex<Vec<Option<String>>>>,
+pub(crate) struct ModelProbeState {
+ pub(crate) key_status: StatusCode,
+ pub(crate) key_calls: Arc<AtomicUsize>,
+ pub(crate) model_calls: Arc<AtomicUsize>,
+ pub(crate) key_authorization: Arc<Mutex<Vec<Option<String>>>>,
+ pub(crate) model_authorization: Arc<Mutex<Vec<Option<String>>>>,
}
async fn openrouter_key_handler(
@@ -90,7 +80,9 @@ fn authorization_header(headers: &HeaderMap) -> Option<String> {
.map(|value| value.to_string())
}
-async fn spawn_openrouter_probe_server(key_status: StatusCode) -> (String, ModelProbeState) {
+pub(crate) async fn spawn_openrouter_probe_server(
+ key_status: StatusCode,
+) -> (String, ModelProbeState) {
let state = ModelProbeState {
key_status,
key_calls: Arc::new(AtomicUsize::new(0)),
@@ -112,7 +104,11 @@ async fn spawn_openrouter_probe_server(key_status: StatusCode) -> (String, Model
(format!("http://{addr}"), state)
}
-async fn configure_openrouter_workspace(tmp: &TempDir, endpoint: String, token: &str) -> Config {
+pub(crate) async fn configure_openrouter_workspace(
+ tmp: &TempDir,
+ endpoint: String,
+ token: &str,
+) -> Config {
let mut config = Config {
config_path: tmp.path().join("config.toml"),
workspace_dir: tmp.path().join("workspace"),
@@ -161,7 +157,7 @@ async fn static_models_handler(State(s): State<StaticResponse>) -> Response {
(s.status, s.body).into_response()
}
-async fn spawn_static_models_server(status: StatusCode, body: &'static str) -> String {
+pub(crate) async fn spawn_static_models_server(status: StatusCode, body: &'static str) -> String {
let listener = tokio::net::TcpListener::bind("127.0.0.1:0")
.await
.expect("bind");
@@ -175,7 +171,7 @@ async fn spawn_static_models_server(status: StatusCode, body: &'static str) -> S
format!("http://{addr}")
}
-async fn configure_generic_workspace(tmp: &TempDir, endpoint: String) -> Config {
+pub(crate) async fn configure_generic_workspace(tmp: &TempDir, endpoint: String) -> Config {
// Non-`openrouter` slug so the OpenRouter pre-validation path is
// skipped and the test hits `/models` directly.
let mut config = Config {
@@ -196,8 +192,3 @@ async fn configure_generic_workspace(tmp: &TempDir, endpoint: String) -> Config
config.save().await.expect("save config");
config
}
-
-#[path = "model_catalog_error_suppression_tests.rs"]
-mod error_suppression_tests;
-#[path = "model_catalog_parsing_tests.rs"]
-mod models_parsing_tests;
diff --git a/crates/openhuman-core/src/inference/provider/model_catalog_error_suppression_tests.rs b/crates/openhuman-core/src/inference/provider/models/catalog_listing_error_tests.rs
similarity index 95%
rename from crates/openhuman-core/src/inference/provider/model_catalog_error_suppression_tests.rs
rename to crates/openhuman-core/src/inference/provider/models/catalog_listing_error_tests.rs
index f240412a81..6b26c91e7c 100644
--- a/crates/openhuman-core/src/inference/provider/model_catalog_error_suppression_tests.rs
+++ b/crates/openhuman-core/src/inference/provider/models/catalog_listing_error_tests.rs
@@ -1,4 +1,9 @@
+use super::catalog_listing::list_configured_models_from_config;
use super::*;
+use crate::inference::provider::model_listing_test_support::{
+ configure_generic_workspace, configure_openrouter_workspace, spawn_openrouter_probe_server,
+ spawn_static_models_server,
+};
#[test]
fn list_configured_models_accepts_slug() {
diff --git a/crates/openhuman-core/src/inference/provider/model_catalog_parsing_tests.rs b/crates/openhuman-core/src/inference/provider/models/catalog_listing_tests.rs
similarity index 97%
rename from crates/openhuman-core/src/inference/provider/model_catalog_parsing_tests.rs
rename to crates/openhuman-core/src/inference/provider/models/catalog_listing_tests.rs
index d4257c3ddf..31e145a99d 100644
--- a/crates/openhuman-core/src/inference/provider/model_catalog_parsing_tests.rs
+++ b/crates/openhuman-core/src/inference/provider/models/catalog_listing_tests.rs
@@ -1,4 +1,9 @@
+use super::catalog_listing::list_configured_models_from_config;
use super::*;
+use crate::inference::provider::model_listing_test_support::{
+ configure_generic_workspace, configure_openrouter_workspace, spawn_openrouter_probe_server,
+ spawn_static_models_server,
+};
#[tokio::test]
async fn list_models_empty_body_returns_diagnostic_error() {
diff --git a/crates/openhuman-core/src/inference/provider/models/mod.rs b/crates/openhuman-core/src/inference/provider/models/mod.rs
index 9dbe2d68dd..36bc7cfb10 100644
--- a/crates/openhuman-core/src/inference/provider/models/mod.rs
+++ b/crates/openhuman-core/src/inference/provider/models/mod.rs
@@ -7,3 +7,11 @@ mod openrouter;
#[cfg(test)]
#[path = "mod_tests.rs"]
mod tests;
+
+#[cfg(test)]
+#[path = "catalog_listing_tests.rs"]
+mod catalog_listing_tests;
+
+#[cfg(test)]
+#[path = "catalog_listing_error_tests.rs"]
+mod catalog_listing_error_tests;
diff --git a/crates/openhuman-core/src/security/mod.rs b/crates/openhuman-core/src/security/mod.rs
index c3c75b878a..329dddabbb 100644
--- a/crates/openhuman-core/src/security/mod.rs
+++ b/crates/openhuman-core/src/security/mod.rs
@@ -20,9 +20,9 @@ pub mod pairing;
pub mod policy;
pub mod prompt_injection;
pub mod scrub;
-pub(crate) mod transport;
pub mod secret_storage;
pub(crate) mod secure_open;
+pub(crate) mod transport;
pub mod turn_origin;
#[allow(unused_imports)]