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(config): use sqlite test backend in config and profile tests
Steven Enamakel788bbd4f09a0
diff --git a/crates/openhuman-core/src/config/schema/load/source/concurrency_tests.rs b/crates/openhuman-core/src/config/schema/load/source/concurrency_tests.rsindex 66f8868cba..57dce73845 100644--- a/crates/openhuman-core/src/config/schema/load/source/concurrency_tests.rs+++ b/crates/openhuman-core/src/config/schema/load/source/concurrency_tests.rs@@ -5,7 +5,7 @@ use serde_json::json;#[tokio::test]async fn agent_registry_rpc_preserves_document_conflicts() {let tmp = tempfile::tempdir().unwrap();- let storage = MemoryStorage::new();+ let storage = memory_backend();let _forced = ForcedDocumentSource::new(scoped(&storage, "tenant-rpc"),Scope::new("tenant-rpc").unwrap(),@@ -48,7 +48,7 @@ async fn agent_registry_rpc_preserves_document_conflicts() {#[tokio::test]async fn memory_engine_rpc_preserves_document_conflicts() {let tmp = tempfile::tempdir().unwrap();- let storage = MemoryStorage::new();+ let storage = memory_backend();let _forced = ForcedDocumentSource::new(scoped(&storage, "tenant-memory-rpc"),Scope::new("tenant-memory-rpc").unwrap(),@@ -91,7 +91,7 @@ mod revision_loader_tests;#[tokio::test]async fn sequential_config_rpcs_use_the_latest_context_snapshot() {let tmp = tempfile::tempdir().unwrap();- let storage = MemoryStorage::new();+ let storage = memory_backend();let _forced = ForcedDocumentSource::new(scoped(&storage, "tenant-sequential-config-rpc"),Scope::new("tenant-sequential-config-rpc").unwrap(),@@ -133,7 +133,7 @@ async fn sequential_config_rpcs_use_the_latest_context_snapshot() {#[tokio::test]async fn external_config_conflict_refreshes_the_context_before_the_next_read() {let tmp = tempfile::tempdir().unwrap();- let storage = MemoryStorage::new();+ let storage = memory_backend();let _forced = ForcedDocumentSource::new(scoped(&storage, "tenant-refresh-config-rpc"),Scope::new("tenant-refresh-config-rpc").unwrap(),@@ -180,7 +180,7 @@ async fn external_config_conflict_refreshes_the_context_before_the_next_read() {#[tokio::test]async fn external_config_conflict_refresh_keeps_derived_runtime_overrides() {let tmp = tempfile::tempdir().unwrap();- let storage = MemoryStorage::new();+ let storage = memory_backend();let _forced = ForcedDocumentSource::new(scoped(&storage, "tenant-refresh-overlay"),Scope::new("tenant-refresh-overlay").unwrap(),@@ -325,7 +325,7 @@ async fn external_config_conflict_refresh_keeps_derived_runtime_overrides() {#[tokio::test]async fn nested_context_refresh_does_not_pin_a_previous_external_value() {let tmp = tempfile::tempdir().unwrap();- let storage = MemoryStorage::new();+ let storage = memory_backend();let _forced = ForcedDocumentSource::new(scoped(&storage, "tenant-refresh-nested-overlay"),Scope::new("tenant-refresh-nested-overlay").unwrap(),@@ -414,7 +414,7 @@ async fn nested_context_refresh_does_not_pin_a_previous_external_value() {#[tokio::test]async fn config_snapshot_cannot_be_saved_into_a_different_tenant_scope() {let tmp = tempfile::tempdir().unwrap();- let storage = MemoryStorage::new();+ let storage = memory_backend();let path = tmp.path().join("config.toml");let workspace = tmp.path().join("workspace");@@ -508,8 +508,8 @@ async fn config_snapshot_is_bound_to_its_backend_instance() {let tmp = tempfile::tempdir().unwrap();let path = tmp.path().join("config.toml");let workspace = tmp.path().join("workspace");- let storage_a = MemoryStorage::new();- let storage_b = MemoryStorage::new();+ let storage_a = memory_backend();+ let storage_b = memory_backend();let config_a = {let _source = ForcedDocumentSource::new(scoped(&storage_a, "tenant-same-anchor"),@@ -599,7 +599,7 @@ async fn a_file_snapshot_can_seed_an_absent_document_after_storage_bootstrap() {Some(ConfigSourceAnchor::File(_))));- let storage = MemoryStorage::new();+ let storage = memory_backend();let _source = ForcedDocumentSource::new(scoped(&storage, "tenant-file-bootstrap"),Scope::new("tenant-file-bootstrap").unwrap(),@@ -619,7 +619,7 @@ async fn a_file_snapshot_can_seed_an_absent_document_after_storage_bootstrap() {#[tokio::test]async fn document_source_write_uses_its_last_read_revision() {let tmp = tempfile::tempdir().unwrap();- let storage = MemoryStorage::new();+ let storage = memory_backend();let path = tmp.path().join("config.toml");let first = document_source(&storage, "tenant-source-cas", &path);let stale = document_source(&storage, "tenant-source-cas", &path);@@ -639,7 +639,7 @@ async fn document_source_write_uses_its_last_read_revision() {#[tokio::test]async fn an_unobserved_document_source_write_is_create_only() {let tmp = tempfile::tempdir().unwrap();- let storage = MemoryStorage::new();+ let storage = memory_backend();let path = tmp.path().join("config.toml");let seed = document_source(&storage, "tenant-source-create-only", &path);let blind = document_source(&storage, "tenant-source-create-only", &path);diff --git a/crates/openhuman-core/src/config/schema/load/source/profile_refresh_tests.rs b/crates/openhuman-core/src/config/schema/load/source/profile_refresh_tests.rsindex 76f3f76490..564a6d52ad 100644--- a/crates/openhuman-core/src/config/schema/load/source/profile_refresh_tests.rs+++ b/crates/openhuman-core/src/config/schema/load/source/profile_refresh_tests.rs@@ -3,7 +3,7 @@ use super::*;#[tokio::test]async fn profile_context_conflict_refresh_keeps_host_owned_restrictions() {let tmp = tempfile::tempdir().unwrap();- let storage = MemoryStorage::new();+ let storage = memory_backend();let _forced = ForcedDocumentSource::new(scoped(&storage, "tenant-profile-refresh"),Scope::new("tenant-profile-refresh").unwrap(),diff --git a/crates/openhuman-core/src/config/schema/load/source/revision_loader_tests.rs b/crates/openhuman-core/src/config/schema/load/source/revision_loader_tests.rsindex 01d1536711..4c8f501180 100644--- a/crates/openhuman-core/src/config/schema/load/source/revision_loader_tests.rs+++ b/crates/openhuman-core/src/config/schema/load/source/revision_loader_tests.rs@@ -7,7 +7,7 @@ use tinytools::Tool;#[tokio::test]async fn discovered_parent_config_is_used_to_record_agent_overrides() {let tmp = tempfile::tempdir().unwrap();- let storage = MemoryStorage::new();+ let storage = memory_backend();let _forced = ForcedDocumentSource::new(scoped(&storage, "tenant-internal-boot-agent"),Scope::new("tenant-internal-boot-agent").unwrap(),@@ -70,7 +70,7 @@ async fn proxy_config_tool_loads_a_versioned_document_before_saving() {let previous_proxy = crate::config::runtime_proxy_config();let _restore = RuntimeProxyRestore(previous_proxy);let tmp = tempfile::tempdir().unwrap();- let storage = MemoryStorage::new();+ let storage = memory_backend();let path = tmp.path().join("config.toml");let workspace = tmp.path().join("workspace");@@ -133,7 +133,7 @@ async fn channel_allowlist_store_loads_a_versioned_document_before_saving() {let tmp = tempfile::tempdir().unwrap();let _env = crate::config::test_env::lock_env_async().await;let _home = crate::config::test_env::EnvVarGuard::set("HOME", tmp.path());- let storage = MemoryStorage::new();+ let storage = memory_backend();let openhuman_dir = tmp.path().join(".openhuman");tokio::fs::create_dir_all(&openhuman_dir).await.unwrap();let config_path = openhuman_dir.join("config.toml");@@ -186,7 +186,7 @@ async fn channel_allowlist_store_loads_a_versioned_document_before_saving() {#[tokio::test]async fn recovery_restores_the_bootstrap_file_when_document_cas_conflicts() {let tmp = tempfile::tempdir().unwrap();- let storage = MemoryStorage::new();+ let storage = memory_backend();let mut recovered = config_at(tmp.path(), "recovered-config");recovered.storage.url = Some("sqlite:/bootstrap-from-recovered-file".into());recovered.save().await.unwrap();diff --git a/crates/openhuman-core/src/profiles/host_storage_tests.rs b/crates/openhuman-core/src/profiles/host_storage_tests.rsindex d059b2cac4..fd10557c51 100644--- a/crates/openhuman-core/src/profiles/host_storage_tests.rs+++ b/crates/openhuman-core/src/profiles/host_storage_tests.rs@@ -1,3 +1,5 @@+#![cfg(feature = "storage-sqlite")]+use super::*;fn profile_id(name: &str) -> ProfileId {@@ -98,8 +100,8 @@ async fn a_backend_supplied_to_profile_host_owns_its_cron_cap() {let mut saas = crate::core::runtime::SaasConfig::new(tmp.path());saas.cron.agent_jobs_only = true;saas.cron.max_active_jobs = 1;- let backend: Arc<dyn crate::storage::StorageBackend> =- Arc::new(crate::storage::MemoryStorage::new());+ let fixture = crate::storage::test_support::sqlite_backend().unwrap();+ let backend = Arc::clone(&fixture.backend);let fences = Arc::new(crate::storage::fence::FenceRegistry::new(crate::profiles::lease::now_ms,));@@ -121,8 +123,8 @@ async fn an_already_fenced_backend_remains_compatible_with_the_public_constructolet mut saas = crate::core::runtime::SaasConfig::new(tmp.path());saas.cron.agent_jobs_only = true;saas.cron.max_active_jobs = 1;- let backend: Arc<dyn crate::storage::StorageBackend> =- Arc::new(crate::storage::MemoryStorage::new());+ let fixture = crate::storage::test_support::sqlite_backend().unwrap();+ let backend = Arc::clone(&fixture.backend);let fences = crate::storage::fence::registry();let supplied: Arc<dyn crate::storage::StorageBackend> =Arc::new(crate::storage::fenced_backend::FencedBackend::new(@@ -147,8 +149,8 @@ async fn the_installed_fenced_backend_is_reused_without_an_extra_wrapper() {let mut saas = crate::core::runtime::SaasConfig::new(tmp.path());saas.cron.agent_jobs_only = true;saas.cron.max_active_jobs = 1;- let backend: Arc<dyn crate::storage::StorageBackend> =- Arc::new(crate::storage::MemoryStorage::new());+ let fixture = crate::storage::test_support::sqlite_backend().unwrap();+ let backend = Arc::clone(&fixture.backend);let fences = crate::storage::fence::registry();let supplied: Arc<dyn crate::storage::StorageBackend> =Arc::new(crate::storage::fenced_backend::FencedBackend::new(