Skip to content

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

refactor(flows): update json accessors in flow tests

Steven Enamakel500b97a05282
diff --git a/crates/openhuman-core/src/flows/builder_tools_draft_id_tests.rs b/crates/openhuman-core/src/flows/builder_tools_draft_id_tests.rs
index d723b7634f..be6138be45 100644
--- a/crates/openhuman-core/src/flows/builder_tools_draft_id_tests.rs
+++ b/crates/openhuman-core/src/flows/builder_tools_draft_id_tests.rs
@@ -200,7 +200,7 @@ async fn save_workflow_by_draft_id_persists_the_draft_graph_onto_the_flow() {
// The draft's graph really landed on the flow.
let saved = ops::flows_get(&config, &flow_id).await.unwrap().value;
- assert_eq!(saved.graph.nodes.len(), 2);
+ assert_eq!(saved.graph["nodes"].as_array().unwrap().len(), 2);
}
#[tokio::test]
diff --git a/crates/openhuman-core/src/flows/builder_tools_save_and_edit_tests.rs b/crates/openhuman-core/src/flows/builder_tools_save_and_edit_tests.rs
index eaf65bfdae..d30540f113 100644
--- a/crates/openhuman-core/src/flows/builder_tools_save_and_edit_tests.rs
+++ b/crates/openhuman-core/src/flows/builder_tools_save_and_edit_tests.rs
@@ -248,7 +248,7 @@ async fn save_workflow_persists_graph_and_name_onto_existing_flow() {
// The graph + name really persisted.
let saved = ops::flows_get(&config, &flow_id).await.unwrap().value;
assert_eq!(saved.name, "AI News Digest");
- assert_eq!(saved.graph.nodes.len(), 2);
+ assert_eq!(saved.graph["nodes"].as_array().unwrap().len(), 2);
}
#[tokio::test]
@@ -271,7 +271,7 @@ async fn save_workflow_rejects_invalid_graph_and_leaves_flow_intact() {
let saved = ops::flows_get(&config, &flow_id).await.unwrap().value;
assert_eq!(saved.name, "Blank flow");
assert_eq!(
- saved.graph.nodes.len(),
+ saved.graph["nodes"].as_array().unwrap().len(),
1,
"original graph must be untouched"
);
@@ -356,7 +356,7 @@ async fn save_workflow_rejects_agent_binding_missing_declared_field() {
let saved = ops::flows_get(&config, &flow_id).await.unwrap().value;
assert_eq!(saved.name, "Blank flow");
assert_eq!(
- saved.graph.nodes.len(),
+ saved.graph["nodes"].as_array().unwrap().len(),
1,
"original graph must be untouched"
);
@@ -399,7 +399,7 @@ async fn save_workflow_accepts_correctly_schemad_graph() {
let saved = ops::flows_get(&config, &flow_id).await.unwrap().value;
assert_eq!(saved.name, "Summarize and notify");
- assert_eq!(saved.graph.nodes.len(), 3);
+ assert_eq!(saved.graph["nodes"].as_array().unwrap().len(), 3);
}
#[tokio::test]
diff --git a/crates/openhuman-core/src/flows/builder_tools_validate_and_create_tests.rs b/crates/openhuman-core/src/flows/builder_tools_validate_and_create_tests.rs
index ddbf109fa4..cad9058032 100644
--- a/crates/openhuman-core/src/flows/builder_tools_validate_and_create_tests.rs
+++ b/crates/openhuman-core/src/flows/builder_tools_validate_and_create_tests.rs
@@ -369,7 +369,7 @@ async fn edit_workflow_surfaces_draft_write_back_failure() {
.query_row(
"SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'docs'",
[],
- |row| row.get(0),
+ |row| row.get::<_, String>(0),
)
.unwrap()
.workflow;
diff --git a/crates/openhuman-core/src/flows/bus_trigger_queue_tests.rs b/crates/openhuman-core/src/flows/bus_trigger_queue_tests.rs
index 2ccd2c50bf..445621bada 100644
--- a/crates/openhuman-core/src/flows/bus_trigger_queue_tests.rs
+++ b/crates/openhuman-core/src/flows/bus_trigger_queue_tests.rs
@@ -24,7 +24,7 @@ async fn schedule_tick_is_coalesced_while_a_trigger_run_is_active() {
if let Some(release) = release_rx.lock().await.take() {
let _ = release.await;
}
- runs_tx.send(request.trigger.as_str()).unwrap();
+ runs_tx.send(request.trigger).unwrap();
}
};
let sub = FlowTriggerSubscriber::with_runner(test_config(&tmp), 1, runner);
@@ -34,7 +34,10 @@ async fn schedule_tick_is_coalesced_while_a_trigger_run_is_active() {
started_rx.await.unwrap();
sub.dispatch_test_schedule(&ctx, "f1").await;
release_tx.send(()).unwrap();
- assert_eq!(runs_rx.recv().await, Some("schedule"));
+ assert_eq!(
+ runs_rx.recv().await,
+ Some(tinyflows_bus::runs::FlowRunTrigger::Schedule)
+ );
assert!(
runs_rx.try_recv().is_err(),
"a busy schedule tick must be dropped"
diff --git a/crates/openhuman-core/src/flows/ops_agent_binding_tests.rs b/crates/openhuman-core/src/flows/ops_agent_binding_tests.rs
index df8aa98317..1c968436b0 100644
--- a/crates/openhuman-core/src/flows/ops_agent_binding_tests.rs
+++ b/crates/openhuman-core/src/flows/ops_agent_binding_tests.rs
@@ -306,16 +306,24 @@ async fn harness_readiness_uses_runtime_role_and_node_override() {
],
"edges": [{"from_node": "t", "to_node": "a"}]
}));
- let node = g.nodes.iter_mut().find(|n| n.id == "a").unwrap();
- assert_eq!(agent_node_role(&config, node).await, "coding");
+ let node = g["nodes"]
+ .as_array_mut()
+ .unwrap()
+ .iter_mut()
+ .find(|node| node["id"] == "a")
+ .unwrap();
+ assert_eq!(agent_node_role(&config, &node["config"]).await, "coding");
config.default_model = Some("hint:reasoning".into());
- assert_eq!(agent_node_role(&config, node).await, "reasoning");
- node.config["model"] = json!("chat-v1");
- assert_eq!(agent_node_role(&config, node).await, "chat");
- node.config["model"] = json!("hint:summarization");
- assert_eq!(agent_node_role(&config, node).await, "summarization");
- node.config["model"] = json!("custom-model-id");
- assert_eq!(agent_node_role(&config, node).await, "chat");
+ assert_eq!(agent_node_role(&config, &node["config"]).await, "reasoning");
+ node["config"]["model"] = json!("chat-v1");
+ assert_eq!(agent_node_role(&config, &node["config"]).await, "chat");
+ node["config"]["model"] = json!("hint:summarization");
+ assert_eq!(
+ agent_node_role(&config, &node["config"]).await,
+ "summarization"
+ );
+ node["config"]["model"] = json!("custom-model-id");
+ assert_eq!(agent_node_role(&config, &node["config"]).await, "chat");
}
#[tokio::test]
diff --git a/crates/openhuman-core/src/flows/ops_builder_trail_off_tests.rs b/crates/openhuman-core/src/flows/ops_builder_trail_off_tests.rs
index 9c6acf888c..d4142d8f05 100644
--- a/crates/openhuman-core/src/flows/ops_builder_trail_off_tests.rs
+++ b/crates/openhuman-core/src/flows/ops_builder_trail_off_tests.rs
@@ -74,7 +74,7 @@ async fn update_records_revisions_and_rollback_restores() {
.await
.unwrap()
.value;
- assert_eq!(rolled.graph.nodes.len(), 1);
+ assert_eq!(rolled.graph["nodes"].as_array().unwrap().len(), 1);
// Rollback is itself undoable — it snapshotted the pre-rollback (2-node) graph.
let history2 = flows_get_history(&config, &flow.id, 20).unwrap().value;
diff --git a/crates/openhuman-core/src/flows/ops_inference_gate_tests.rs b/crates/openhuman-core/src/flows/ops_inference_gate_tests.rs
index 568fcadb58..e302d8be24 100644
--- a/crates/openhuman-core/src/flows/ops_inference_gate_tests.rs
+++ b/crates/openhuman-core/src/flows/ops_inference_gate_tests.rs
@@ -217,9 +217,14 @@ async fn agent_node_role_prefers_custom_registry_entry_model_pin_over_default()
],
"edges": [ { "from_node": "t", "to_node": "a" } ]
}));
- let node = g.nodes.iter().find(|n| n.id == "a").expect("node 'a'");
+ let node = g["nodes"]
+ .as_array()
+ .unwrap()
+ .iter()
+ .find(|node| node["id"] == "a")
+ .expect("node 'a'");
assert_eq!(
- agent_node_role(&config, node).await,
+ agent_node_role(&config, &node["config"]).await,
"reasoning",
"the custom registry entry's `hint:reasoning` pin must win over the default role"
);
diff --git a/crates/openhuman-core/src/flows/ops_run_lifecycle_tests.rs b/crates/openhuman-core/src/flows/ops_run_lifecycle_tests.rs
index eb6279fe3d..49b9f5d185 100644
--- a/crates/openhuman-core/src/flows/ops_run_lifecycle_tests.rs
+++ b/crates/openhuman-core/src/flows/ops_run_lifecycle_tests.rs
@@ -154,7 +154,7 @@ async fn flows_update_replaces_name_and_graph() {
.unwrap();
assert_eq!(updated.value.name, "renamed");
- assert_eq!(updated.value.graph.name, "renamed-graph");
+ assert_eq!(updated.value.graph["name"], "renamed-graph");
}
#[tokio::test]
diff --git a/crates/openhuman-core/src/flows/ops_run_status_and_prompt_binding_tests.rs b/crates/openhuman-core/src/flows/ops_run_status_and_prompt_binding_tests.rs
index a1a910132c..a9a14293d1 100644
--- a/crates/openhuman-core/src/flows/ops_run_status_and_prompt_binding_tests.rs
+++ b/crates/openhuman-core/src/flows/ops_run_status_and_prompt_binding_tests.rs
@@ -117,7 +117,9 @@ fn agent_prompt_binding_unaffected() {
],
"edges": [ { "from_node": "t", "to_node": "summarize" } ]
}));
- assert!(tinyflows::gates::failures(&g).is_empty());
+ let engine_graph: tinyflows::model::WorkflowGraph =
+ serde_json::from_value(g.clone()).expect("graph fixture converts to engine graph");
+ assert!(tinyflows::gates::failures(&engine_graph).is_empty());
}
/// Regression for issue #4593 (widened for #4881's `resume_flow_run`/
diff --git a/crates/openhuman-core/src/flows/ops_tests.rs b/crates/openhuman-core/src/flows/ops_tests.rs
index e3e91d879a..a5e2d7fb05 100644
--- a/crates/openhuman-core/src/flows/ops_tests.rs
+++ b/crates/openhuman-core/src/flows/ops_tests.rs
@@ -138,7 +138,7 @@ async fn flows_import_uses_the_tinyflows_authoring_module_in_a_cold_process() {
.await
.expect("valid native graph imports")
.value;
- assert_eq!(result.graph.name, "constant import");
+ assert_eq!(result.graph["name"], "constant import");
assert_eq!(
crate::modules::state_of("tinyflows"),
crate::modules::ModuleState::Ready,
diff --git a/crates/openhuman-core/src/flows/ops_triggers_and_resume_tests.rs b/crates/openhuman-core/src/flows/ops_triggers_and_resume_tests.rs
index c57fc44afc..9d07ec8d07 100644
--- a/crates/openhuman-core/src/flows/ops_triggers_and_resume_tests.rs
+++ b/crates/openhuman-core/src/flows/ops_triggers_and_resume_tests.rs
@@ -268,7 +268,7 @@ async fn flows_update_does_not_rebind_schedule_for_pinned_input_changes() {
"the flow remains enabled during the edit"
);
assert_eq!(
- updated.value.graph.trigger().unwrap().config["inputs"]["team"],
+ updated.value.graph["nodes"][0]["config"]["inputs"]["team"],
"platform",
"the input edit must be persisted for this rebind regression"
);