Skip to content

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

test(storage): add backend install helper for tests

Steven Enamakel3e16e3b95be8
diff --git a/crates/openhuman-core/src/inference/provider/factory_crate_native_cloud_tests.rs b/crates/openhuman-core/src/inference/provider/factory_crate_native_cloud_tests.rs
index 03a57b3bfa..55acc9dc7a 100644
--- a/crates/openhuman-core/src/inference/provider/factory_crate_native_cloud_tests.rs
+++ b/crates/openhuman-core/src/inference/provider/factory_crate_native_cloud_tests.rs
@@ -276,6 +276,9 @@ async fn native_claude_turn_routes_disclose_pinned_models() {
use std::time::Duration;
let _guard = crate::inference::inference_test_guard_async().await;
+ let _storage = crate::storage::test_support::install_backend_for_test(
+ crate::storage::test_support::memory_backend(),
+ );
crate::core::bus::init().await.expect("bus init");
let mut rx = crate::core::bus::BUS.get().unwrap().receiver();
diff --git a/crates/openhuman-core/src/inference/provider/factory_crate_native_diagnostics_tests.rs b/crates/openhuman-core/src/inference/provider/factory_crate_native_diagnostics_tests.rs
index f723413633..24408106fc 100644
--- a/crates/openhuman-core/src/inference/provider/factory_crate_native_diagnostics_tests.rs
+++ b/crates/openhuman-core/src/inference/provider/factory_crate_native_diagnostics_tests.rs
@@ -95,6 +95,9 @@ async fn from_string_external_provider_emits_egress_realpath() {
#[tokio::test]
async fn caller_owned_models_build_without_openhuman_session() {
let _guard = crate::inference::inference_test_guard_async().await;
+ let _storage = crate::storage::test_support::install_backend_for_test(
+ crate::storage::test_support::memory_backend(),
+ );
let _signed_out = crate::platform::llm_gate::SignedOutTestGuard::set(true);
let dir = tempfile::tempdir().unwrap();
let config = Config {
diff --git a/crates/openhuman-core/src/inference/provider/factory_crate_native_tests.rs b/crates/openhuman-core/src/inference/provider/factory_crate_native_tests.rs
index e537d2f839..d38708cc66 100644
--- a/crates/openhuman-core/src/inference/provider/factory_crate_native_tests.rs
+++ b/crates/openhuman-core/src/inference/provider/factory_crate_native_tests.rs
@@ -603,6 +603,9 @@ async fn native_claude_turn_routes_disclose_pinned_models() {
use std::time::Duration;
let _guard = crate::inference::inference_test_guard_async().await;
+ let _storage = crate::storage::test_support::install_backend_for_test(
+ crate::storage::test_support::memory_backend(),
+ );
crate::core::bus::init().await.expect("bus init");
let mut rx = crate::core::bus::BUS.get().unwrap().receiver();
diff --git a/crates/openhuman-core/src/storage/test_support.rs b/crates/openhuman-core/src/storage/test_support.rs
index dcdd6f2079..5eb8a175fa 100644
--- a/crates/openhuman-core/src/storage/test_support.rs
+++ b/crates/openhuman-core/src/storage/test_support.rs
@@ -60,6 +60,19 @@ pub fn install_for_test(url: &str, backend: Arc<dyn StorageBackend>) -> Installe
}
}
+/// Installs a backend for tests that need scoped storage but do not exercise
+/// the configured-URL boot path.
+pub fn install_backend_for_test(backend: Arc<dyn StorageBackend>) -> InstalledBackendGuard {
+ let slot_lock = lock_storage_slot();
+ let previous_url = crate::storage::installed_url();
+ let previous_backend = crate::storage::install(backend);
+ InstalledBackendGuard {
+ _slot_lock: slot_lock,
+ previous_backend,
+ previous_url,
+ }
+}
+
impl Drop for InstalledBackendGuard {
fn drop(&mut self) {
match (self.previous_backend.take(), self.previous_url.take()) {