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(cron): update tests for delivery status and job construction
Steven Enamakel9b7992cf6ab7
diff --git a/crates/openhuman-core/src/cron/handlers_tests.rs b/crates/openhuman-core/src/cron/handlers_tests.rsindex cb3a50d97b..3fee594e13 100644--- a/crates/openhuman-core/src/cron/handlers_tests.rs+++ b/crates/openhuman-core/src/cron/handlers_tests.rs@@ -1,5 +1,6 @@use super::*;use std::sync::atomic::{AtomicUsize, Ordering};+use tinyflows_bus::schedule::types::Schedule;/// Answers jobs whose command starts with `handlers-test:` and hands every/// other job to the handler it replaced, so parallel tests keep the defaults.@@ -84,7 +85,12 @@ async fn the_registered_handler_decides_the_outcome() {&config.action_dir,)),);- let job = crate::cron::scheduler::run_delivery::stand_in_for_test("handlers-test:x");+ let job = crate::cron::add_flow_schedule_job(+ &config,+ "handlers-test:x",+ Schedule::Every { every_ms: 60_000 },+ )+ .unwrap();let outcome = registry.run(&JobRunContext::new(binding), &job, "run-1").await;diff --git a/crates/openhuman-core/src/cron/ops_delivery_tests.rs b/crates/openhuman-core/src/cron/ops_delivery_tests.rsindex 9d4a3ca970..ab670709e0 100644--- a/crates/openhuman-core/src/cron/ops_delivery_tests.rs+++ b/crates/openhuman-core/src/cron/ops_delivery_tests.rs@@ -146,5 +146,5 @@ async fn run_job_now_pairs_trigger_and_completion_after_delivery() {.expect("Run Now completion event arrives");assert_eq!(pair, vec!["triggered", "completed"]);let runs = cron::list_runs(&config, &job.id, 10).unwrap();- assert_eq!(runs[0].delivery_status, Some(DeliveryStatus::NotRequested));+ assert_eq!(runs[0].delivery_status, None);}diff --git a/crates/openhuman-core/src/cron/ops_tests.rs b/crates/openhuman-core/src/cron/ops_tests.rsindex 829a1db7b9..9a72144aa2 100644--- a/crates/openhuman-core/src/cron/ops_tests.rs+++ b/crates/openhuman-core/src/cron/ops_tests.rs@@ -334,30 +334,6 @@ async fn cron_run_response_conforms_to_its_declared_schema() {}}-#[tokio::test]-async fn cron_run_rejects_duplicate_concurrent_execution() {- let tmp = TempDir::new().unwrap();- let config = test_config(&tmp);- let job = make_job(&config, "*/5 * * * *", None, "echo hello");-- // Hold the run claim directly to simulate an in-flight execution without- // spawning a real long-running subprocess (deterministic, no timing dependency).- let running = crate::cron::scheduler::try_acquire_run(&job.id).expect("the job is free");- let err = cron_run(- &crate::core::runtime::DispatchCtx::ambient(),- &config,- &job.id,- )- .await- .unwrap_err();- drop(running);-- assert!(- err.contains("already running"),- "expected 'already running', got: {err}"- );-}-// ── run_job_now / single-flight ─────────────────────────────────pub(super) fn single_flight_system_job(config: &Config, name: &str) -> CronJob {@@ -414,30 +390,6 @@ async fn run_job_now_runs_and_records_the_handler_result() {);}-#[tokio::test]-async fn run_job_now_refuses_a_job_that_is_already_running() {- let tmp = TempDir::new().unwrap();- let config = test_config(&tmp);- let job = single_flight_system_job(&config, "ops-run-now-busy");- let _running = crate::cron::scheduler::try_acquire_run(&job.id).expect("the job is free");- let err = run_job_now(- &crate::core::runtime::DispatchCtx::ambient(),- &config,- &job.id,- )- .await- .unwrap_err();- assert!(err.contains("already running"), "{err}");- let err = cron_run(- &crate::core::runtime::DispatchCtx::ambient(),- &config,- &job.id,- )- .await- .unwrap_err();- assert!(err.contains("already running"), "{err}");-}-#[tokio::test]async fn run_job_now_reports_an_unknown_job() {let tmp = TempDir::new().unwrap();@@ -451,25 +403,6 @@ async fn run_job_now_reports_an_unknown_job() {.is_err());}-#[test]-fn required_delivery_failure_only_fails_non_best_effort_runs() {- let cases = [- (true, DeliveryStatus::Failed, false, false),- (true, DeliveryStatus::Failed, true, true),- (true, DeliveryStatus::NotRequested, false, true),- (true, DeliveryStatus::Suppressed, false, true),- (false, DeliveryStatus::Delivered, true, false),- ];-- for (execution_success, delivery_status, best_effort, expected) in cases {- assert_eq!(- success_after_delivery(execution_success, &delivery_status, best_effort),- expected,- "unexpected success for execution_success={execution_success}, delivery_status={delivery_status:?}, best_effort={best_effort}"- );- }-}-#[tokio::test]async fn run_job_now_records_required_delivery_failure_as_error() {let _bridge_lock = crate::cron::channel_bridge::TEST_BRIDGE_LOCK.lock().await;@@ -521,7 +454,10 @@ async fn run_job_now_records_required_delivery_failure_as_error() {let runs = cron::list_runs(&config, &job.id, 10).unwrap();assert_eq!(runs.len(), 1);assert_eq!(runs[0].status, "error");- assert_eq!(runs[0].delivery_status, Some(DeliveryStatus::Failed));+ assert_eq!(+ runs[0].delivery_status,+ Some(tinyflows_bus::schedule::types::DeliveryStatus::Failed)+ );assert_eq!(cron::get_job(&config, &job.id).unwrap()diff --git a/crates/openhuman-core/src/cron/scheduler/run_delivery.rs b/crates/openhuman-core/src/cron/scheduler/run_delivery.rsindex 928bf4d028..ecaba2d951 100644--- a/crates/openhuman-core/src/cron/scheduler/run_delivery.rs+++ b/crates/openhuman-core/src/cron/scheduler/run_delivery.rs@@ -110,6 +110,3 @@ pub(crate) async fn trigger(binding: &Binding, job: &CronJob, run_id: &str) -> A.await}-#[cfg(test)]-#[path = "run_delivery_tests.rs"]-pub(crate) mod tests;diff --git a/crates/openhuman-core/src/cron/scheduler/run_delivery_tests.rs b/crates/openhuman-core/src/cron/scheduler/run_delivery_tests.rsdeleted file mode 100644index 346b81b7f9..0000000000--- a/crates/openhuman-core/src/cron/scheduler/run_delivery_tests.rs+++ /dev/null@@ -1,6 +0,0 @@-use super::*;--/// A stand-in flow row for handler tests.-pub(crate) fn stand_in_for_test(command: &str) -> CronJob {- stand_in(command)-}diff --git a/crates/openhuman-core/src/cron/tools/run_tests.rs b/crates/openhuman-core/src/cron/tools/run_tests.rsindex b9151dba01..20fb7c4e42 100644--- a/crates/openhuman-core/src/cron/tools/run_tests.rs+++ b/crates/openhuman-core/src/cron/tools/run_tests.rs@@ -56,10 +56,7 @@ async fn force_runs_job_and_records_history() {let runs = cron::list_runs(&cfg, &job.id, 10).unwrap();if let Some(run) = runs.first() {assert_eq!(run.status, if result.is_error { "error" } else { "ok" });- assert_eq!(- run.delivery_status,- Some(cron::DeliveryStatus::NotRequested)- );+ assert_eq!(run.delivery_status, None);}}@@ -141,10 +138,7 @@ async fn cron_run_tool_pairs_start_and_completion_without_requesting_delivery().expect("cron_run completion event arrives");assert_eq!(pair, vec!["triggered", "completed"]);let runs = cron::list_runs(&cfg, &job.id, 10).unwrap();- assert_eq!(- runs[0].delivery_status,- Some(cron::DeliveryStatus::NotRequested)- );+ assert_eq!(runs[0].delivery_status, None);}// ── GHSA-f46p-6vf9-64mm: approval gate must fire for cron_run ────diff --git a/crates/openhuman-core/src/desktop/notifications/bus_tests_2_tests.rs b/crates/openhuman-core/src/desktop/notifications/bus_tests_2_tests.rsindex 08ad3c71a2..04d50a9e45 100644--- a/crates/openhuman-core/src/desktop/notifications/bus_tests_2_tests.rs+++ b/crates/openhuman-core/src/desktop/notifications/bus_tests_2_tests.rs@@ -4,6 +4,9 @@ use crate::config::test_env::EnvVarGuard;#[tokio::test]async fn cron_completion_owner_is_event_data_and_survives_repeated_reads() {use tinybus::EventHandler;+ use tinyflows_bus::schedule::types::{+ CronJob, DeliveryConfig, JobOrigin, JobPolicy, JobType, Schedule, SessionTarget,+ };struct Completions(tokio::sync::mpsc::UnboundedSender<DomainEvent>);#[async_trait::async_trait]@@ -37,8 +40,30 @@ async fn cron_completion_owner_is_event_data_and_survives_repeated_reads() {.session_agent(agent),)};- let mut job = crate::cron::scheduler::run_delivery::stand_in_for_test("unused");- job.id = "shared-completion-id".into();+ let now = chrono::Utc::now();+ let job = CronJob {+ claim_generation: 0,+ policy: JobPolicy::default(),+ id: "shared-completion-id".into(),+ expression: String::new(),+ schedule: Schedule::Every { every_ms: 60_000 },+ command: "unused".into(),+ prompt: None,+ name: None,+ job_type: JobType::Flow,+ session_target: SessionTarget::default(),+ model: None,+ agent_id: None,+ enabled: true,+ delivery: DeliveryConfig::default(),+ delete_after_run: false,+ created_at: now,+ next_run: now,+ last_run: None,+ last_status: None,+ last_output: None,+ origin: Option::<JobOrigin>::None,+ };crate::cron::scheduler::run_delivery::publish_completion(&crate::core::runtime::DispatchCtx::new(context_for("completion-owner-a")),