Skip to content

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

test(profiles): give profile host tests a real SQLite backend

Steven Enamakel0c45d6c74ea8
diff --git a/crates/openhuman-core/src/profiles/background_tests.rs b/crates/openhuman-core/src/profiles/background_tests.rs
index 055113bc83..4e975700aa 100644
--- a/crates/openhuman-core/src/profiles/background_tests.rs
+++ b/crates/openhuman-core/src/profiles/background_tests.rs
@@ -9,7 +9,17 @@ use tinymemory_tools::BackgroundJob;
fn host(tmp: &tempfile::TempDir, idle_secs: u64) -> ProfileHost {
let mut saas = SaasConfig::new(tmp.path());
saas.idle_evict_secs = idle_secs;
- ProfileHost::new(saas, CoreContext::for_test(DomainSet::full(), None))
+ let backend_path = tmp.path().join("profile-storage");
+ let backend_url = format!("sqlite:{}", backend_path.display());
+ let backend =
+ crate::storage::block_on_anyhow(async { crate::storage::open(&backend_url).await })
+ .expect("profile test SQLite backend opens");
+ ProfileHost::with_backend(
+ saas,
+ CoreContext::for_test(DomainSet::full(), None),
+ Some(backend),
+ )
+ .expect("profile test host uses conditional SQLite leases")
}
fn build_job() -> BackgroundJob {
diff --git a/crates/openhuman-core/src/profiles/host_tests.rs b/crates/openhuman-core/src/profiles/host_tests.rs
index 1aad02c3c8..583860f07a 100644
--- a/crates/openhuman-core/src/profiles/host_tests.rs
+++ b/crates/openhuman-core/src/profiles/host_tests.rs
@@ -245,7 +245,17 @@ fn host(tmp: &tempfile::TempDir, max_open: usize, idle_secs: u64) -> ProfileHost
let mut saas = SaasConfig::new(tmp.path());
saas.max_profiles_open = max_open;
saas.idle_evict_secs = idle_secs;
- ProfileHost::new(saas, CoreContext::for_test(DomainSet::full(), None))
+ let backend_path = tmp.path().join("profile-storage");
+ let backend_url = format!("sqlite:{}", backend_path.display());
+ let backend =
+ crate::storage::block_on_anyhow(async { crate::storage::open(&backend_url).await })
+ .expect("profile test SQLite backend opens");
+ ProfileHost::with_backend(
+ saas,
+ CoreContext::for_test(DomainSet::full(), None),
+ Some(backend),
+ )
+ .expect("profile test host uses conditional SQLite leases")
}
fn profile(name: &str) -> ProfileId {
diff --git a/crates/openhuman-core/src/profiles/lifecycle.rs b/crates/openhuman-core/src/profiles/lifecycle.rs
index 5028272e71..cb30f8a793 100644
--- a/crates/openhuman-core/src/profiles/lifecycle.rs
+++ b/crates/openhuman-core/src/profiles/lifecycle.rs
@@ -45,13 +45,6 @@ pub(super) async fn reconcile_cron_admission(
id: &ProfileId,
backend: Option<&Arc<dyn crate::storage::StorageBackend>>,
) -> Result<(), String> {
- // A profile's fenced cron writes require atomic storage conditions. The
- // default unit-test backend intentionally lacks them, so use the same
- // persistent SQLite default as production when no host backend is set.
- #[cfg(all(test, feature = "storage-sqlite"))]
- if backend.is_none() && crate::storage::installed().is_none() {
- crate::storage::local::use_persistent_default_for_test(&config.workspace_dir);
- }
let profile_scope = crate::storage::scope_for_profile(id.as_str());
let scope = match backend {
Some(backend) => crate::cron::documents_port::DocScope::on_backend(