Skip to content

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

test(embedding_host): replace env-var dance with config.api_url in factory tests

Steven Enamakel0277891b4746
diff --git a/crates/openhuman-core/src/inference/embedding_host/factory_tests.rs b/crates/openhuman-core/src/inference/embedding_host/factory_tests.rs
index 311759f1dc..0d60b5cd0d 100644
--- a/crates/openhuman-core/src/inference/embedding_host/factory_tests.rs
+++ b/crates/openhuman-core/src/inference/embedding_host/factory_tests.rs
@@ -346,30 +346,21 @@ async fn factory_managed_provider_authenticates_with_config_scoped_token() {
)
.unwrap();
- // `OpenHumanCloudEmbedding::new` bakes the base URL at construction, so
- // BACKEND_URL only needs to point at the mock while the factory builds —
- // held under the crate-wide backend-env lock (shared with
- // `openhuman_tinyhumans::backend::url`'s own BACKEND_URL tests) so the
- // process-global env can't race.
- let provider = {
- let _env_guard = crate::config::app_env::env_test_lock();
- let prev = std::env::var("BACKEND_URL").ok();
- std::env::set_var("BACKEND_URL", &base);
- let built = create_embedding_provider_with_config(
- &config,
- "managed",
- "voyage-3-large",
- 3,
- "",
- None,
- )
- .expect("managed provider builds via config-aware factory");
- match prev {
- Some(v) => std::env::set_var("BACKEND_URL", v),
- None => std::env::remove_var("BACKEND_URL"),
- }
- built
+ // The managed base URL comes from the backend transport, which (the
+ // `cfg(test)` plain one here) honours `config.api_url`: point it at the mock.
+ let config = Config {
+ api_url: Some(base.clone()),
+ ..config
};
+ let provider = create_embedding_provider_with_config(
+ &config,
+ "managed",
+ "voyage-3-large",
+ 3,
+ "",
+ None,
+ )
+ .expect("managed provider builds via config-aware factory");
// Embed: the lazy bearer resolver reads the config scope, finds the
// token, and authenticates to the mock.
@@ -446,17 +437,11 @@ async fn default_provider_with_config_authenticates_with_config_scoped_token() {
)
.unwrap();
- let provider = {
- let _env_guard = crate::config::app_env::env_test_lock();
- let prev = std::env::var("BACKEND_URL").ok();
- std::env::set_var("BACKEND_URL", &base);
- let built = default_embedding_provider_with_config(&config);
- match prev {
- Some(v) => std::env::set_var("BACKEND_URL", v),
- None => std::env::remove_var("BACKEND_URL"),
- }
- built
+ let config = Config {
+ api_url: Some(base.clone()),
+ ..config
};
+ let provider = default_embedding_provider_with_config(&config);
let vectors = provider
.embed(&["binding probe"])