Skip to content

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

test(storage): run tinyflows import tests on sqlite backend

Steven Enamakelf34482a8debb
diff --git a/crates/openhuman-core/src/storage/import/tinyflows_cron_tests.rs b/crates/openhuman-core/src/storage/import/tinyflows_cron_tests.rs
index 0a0ed33193..cbb890a9a4 100644
--- a/crates/openhuman-core/src/storage/import/tinyflows_cron_tests.rs
+++ b/crates/openhuman-core/src/storage/import/tinyflows_cron_tests.rs
@@ -1,6 +1,11 @@
+#![cfg(feature = "storage-sqlite")]
+
use super::*;
use crate::cron::client::testing as cron_store;
-use crate::storage::MemoryStorage;
+use crate::storage::test_support::sqlite_backend;
+use std::ops::Deref;
+use std::sync::Arc;
+use crate::storage::StorageBackend;
fn copy_tree(from: &Path, to: &Path) {
std::fs::create_dir_all(to).unwrap();
@@ -27,9 +32,9 @@ fn run_with_imports_legacy_cron_jobs_whatever_the_flows_gate() {
workspace_dir: dir.path().to_path_buf(),
..Config::default()
};
- let backend: Arc<dyn StorageBackend> = Arc::new(MemoryStorage::new());
+ let backend = sqlite_backend().unwrap();
- let reports = run_with(&backend, &config);
+ let reports = run_with(&backend.backend, &config);
let cron = reports
.iter()
.find(|report| report.domain == CRON_DOMAIN)
@@ -38,6 +43,6 @@ fn run_with_imports_legacy_cron_jobs_whatever_the_flows_gate() {
Outcome::Imported { written, .. } => assert!(*written > 0),
other => panic!("expected the cron jobs to import, got {other:?}"),
}
- let jobs = cron_store::list_jobs(&backend, &Scope::local()).unwrap();
+ let jobs = cron_store::list_jobs(&backend.backend, &Scope::local()).unwrap();
assert!(!jobs.is_empty());
}
diff --git a/crates/openhuman-core/src/storage/import/tinyflows_tests.rs b/crates/openhuman-core/src/storage/import/tinyflows_tests.rs
index 0fd7825faa..7a23894da8 100644
--- a/crates/openhuman-core/src/storage/import/tinyflows_tests.rs
+++ b/crates/openhuman-core/src/storage/import/tinyflows_tests.rs
@@ -1,10 +1,14 @@
use super::*;
use crate::cron::client::testing as cron_store;
-use crate::storage::{MemoryStorage, Scope};
+#![cfg(feature = "storage-sqlite")]
+
+use crate::storage::Scope;
+use crate::storage::test_support::{SqliteBackend, sqlite_backend};
use serde_json::Value;
use serde_json::json;
use sha2::Digest;
use std::collections::BTreeMap;
+use std::ops::Deref;
use tempfile::TempDir;
use tinyflows::engine::Checkpointer;
use tinyflows_drivers::DriverCheckpointer;
@@ -42,8 +46,18 @@ fn workspace() -> (TempDir, Config) {
(dir, config)
}
-fn backend() -> Arc<dyn StorageBackend> {
- Arc::new(MemoryStorage::new())
+struct TestBackend(SqliteBackend);
+
+impl Deref for TestBackend {
+ type Target = Arc<dyn StorageBackend>;
+
+ fn deref(&self) -> &Self::Target {
+ &self.0.backend
+ }
+}
+
+fn backend() -> TestBackend {
+ TestBackend(sqlite_backend().unwrap())
}
/// Every file under `root` with a digest of its bytes. SQLite's `-shm` index
@@ -425,6 +439,7 @@ async fn fallback_backend_migrates_legacy_catalog_state_without_importing_files(
}
let (dir, mut config) = workspace();
+ let _slot = crate::storage::test_support::lock_storage_slot();
config.components.tinyflows = true;
let legacy_dir = dir.path().join("flows");
let legacy_files_before = tree(&legacy_dir);