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(embed): cover storage seam install and restore
Steven Enamakel81b457870b20
diff --git a/crates/openhuman-embed/src/runtime/mod.rs b/crates/openhuman-embed/src/runtime/mod.rsindex cea3d092fd..911b32530b 100644--- a/crates/openhuman-embed/src/runtime/mod.rs+++ b/crates/openhuman-embed/src/runtime/mod.rs@@ -81,6 +81,7 @@ pub use builder::{ConfigSource, RuntimeBuilder};pub use lifecycle::RemoveAgent;pub use run::run_from_args;#[doc(hidden)]+pub use seams::StorageSource;pub use summary::BuilderSummary;use std::collections::HashMap;diff --git a/crates/openhuman-embed/src/runtime/seams_tests.rs b/crates/openhuman-embed/src/runtime/seams_tests.rsindex bc648371cb..6351bfe27a 100644--- a/crates/openhuman-embed/src/runtime/seams_tests.rs+++ b/crates/openhuman-embed/src/runtime/seams_tests.rs@@ -249,3 +249,72 @@ fn builder_options_collect_into_the_seams() {assert!(builder.seams.live_policy.is_some());assert!(builder.seams.server_launcher.is_none());}++static STORAGE_LOCK: std::sync::Mutex<()> = std::sync::Mutex::new(());++async fn memory_backend() -> Arc<dyn openhuman_core::storage::StorageBackend> {+ openhuman_core::storage::open("memory")+ .await+ .expect("memory backend")+}++#[tokio::test]+async fn a_storage_url_is_opened_installed_and_the_previous_backend_restored() {+ let _lock = STORAGE_LOCK.lock().unwrap_or_else(|e| e.into_inner());+ let previous = memory_backend().await;+ openhuman_core::storage::install(Arc::clone(&previous));++ let mut seams = HostSeams {+ storage: Some(StorageSource::from("memory")),+ ..HostSeams::default()+ };+ seams.open_storage().await.expect("open");+ let installed = seams.install().expect("install");+ let ours = openhuman_core::storage::installed().expect("ours installed");+ assert!(!Arc::ptr_eq(&ours, &previous), "the seam installed its own");++ drop(installed);+ let now = openhuman_core::storage::installed().expect("previous restored");+ assert!(Arc::ptr_eq(&now, &previous));+ openhuman_core::storage::clear();+}++#[tokio::test]+async fn a_backend_with_no_predecessor_is_cleared_and_a_replaced_one_left_alone() {+ let _lock = STORAGE_LOCK.lock().unwrap_or_else(|e| e.into_inner());+ openhuman_core::storage::clear();++ let backend = memory_backend().await;+ let installed = HostSeams {+ storage: Some(StorageSource::Backend(Arc::clone(&backend))),+ ..HostSeams::default()+ }+ .install()+ .expect("install");+ assert!(openhuman_core::storage::installed().is_some());+ drop(installed);+ assert!(openhuman_core::storage::installed().is_none());++ let installed = HostSeams {+ storage: Some(StorageSource::Backend(backend)),+ ..HostSeams::default()+ }+ .install()+ .expect("install");+ let later = memory_backend().await;+ openhuman_core::storage::install(Arc::clone(&later));+ drop(installed);+ let now = openhuman_core::storage::installed().expect("later kept");+ assert!(Arc::ptr_eq(&now, &later));+ openhuman_core::storage::clear();+}++#[tokio::test]+async fn an_unopenable_storage_url_fails_the_open() {+ let mut seams = HostSeams {+ storage: Some(StorageSource::from("nonsense://nowhere")),+ ..HostSeams::default()+ };+ let error = seams.open_storage().await.expect_err("bad url");+ assert!(error.contains("storage backend"), "{error}");+}