Skip to content

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

chore(tinyflows): add tests for state and import handling

Steven Enamakelf20395336b2f
diff --git a/crates/openhuman-core/src/flows/tinyflows/state_tests.rs b/crates/openhuman-core/src/flows/tinyflows/state_tests.rs
index 9376b1b015..a38c73f5d4 100644
--- a/crates/openhuman-core/src/flows/tinyflows/state_tests.rs
+++ b/crates/openhuman-core/src/flows/tinyflows/state_tests.rs
@@ -4,7 +4,11 @@ use serde_json::json;
use tinyflows_drivers::catalog::FlowCatalogDocuments;
fn documents(namespace: &str) -> FlowState {
- let scoped = MemoryStorage::new()
+ documents_on(&MemoryStorage::new(), namespace)
+}
+
+fn documents_on(storage: &MemoryStorage, namespace: &str) -> FlowState {
+ let scoped = storage
.for_scope(&Scope::new("local").unwrap())
.unwrap();
FlowState::Documents(FlowStateDocuments::new(
@@ -41,7 +45,11 @@ async fn the_workspace_database_backs_both_views() {
#[tokio::test(flavor = "multi_thread")]
async fn namespaces_keep_flows_apart() {
- let (a, b) = (documents("flow:a"), documents("flow:b"));
+ let storage = MemoryStorage::new();
+ let (a, b) = (
+ documents_on(&storage, "flow:a"),
+ documents_on(&storage, "flow:b"),
+ );
a.store("k", json!(1)).await.unwrap();
assert_eq!(b.load("k").await.unwrap(), None);
}
diff --git a/crates/openhuman-core/src/storage/import/tinyflows_tests.rs b/crates/openhuman-core/src/storage/import/tinyflows_tests.rs
index 01bd0562e2..265395a38f 100644
--- a/crates/openhuman-core/src/storage/import/tinyflows_tests.rs
+++ b/crates/openhuman-core/src/storage/import/tinyflows_tests.rs
@@ -6,6 +6,7 @@ use std::collections::BTreeMap;
use tempfile::TempDir;
use tinyflows_drivers::catalog::FlowCatalogDocuments;
use tinyflows_drivers::schedule::CronDocuments;
+use tinyflows::engine::Checkpointer;
use tinyflows_drivers::DriverCheckpointer;
fn fixtures() -> PathBuf {
@@ -97,8 +98,7 @@ fn the_flow_catalog_comes_across_whole_and_the_legacy_files_are_untouched() {
let outcome = import_flows(&backend, &Scope::local(), &config).unwrap();
assert!(written(outcome) > 0);
- let expected = expected();
- let expected = &expected["catalog"];
+ let expected = expected()["catalog"].clone();
let catalog = FlowCatalogDocuments::new(documents(&backend, &Scope::local()));
crate::storage::block_on_anyhow(async move {
let (flows, _) = catalog.list_flows().await?;
@@ -158,8 +158,7 @@ fn flow_checkpoints_come_across_with_their_lineage() {
let checkpointer =
DriverCheckpointer::<Value>::new(documents(&backend, &Scope::local()));
- let expected = expected();
- let expected = &expected["checkpoints"];
+ let expected = expected()["checkpoints"].clone();
crate::storage::block_on_anyhow(async move {
for thread in ["run-1", "Run Two/Upper"] {
let imported = checkpointer.get_thread(thread).await?;
@@ -188,8 +187,7 @@ fn cron_jobs_and_runs_come_across_with_their_fields() {
let outcome = import_cron(&backend, &Scope::local(), &config, dir.path(), "").unwrap();
assert_eq!(written(outcome), 3 + 4);
- let expected = expected();
- let expected = &expected["cron"];
+ let expected = expected()["cron"].clone();
let cron = CronDocuments::new(documents(&backend, &Scope::local()));
crate::storage::block_on_anyhow(async move {
for legacy in expected["jobs"].as_array().unwrap() {