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
chore: files changed crates/openhuman-core/src/cron/scheduler_classifier_and_delivery_tests.rs,crate
Steven Enamakeld6fe3873a1cc
diff --git a/crates/openhuman-core/src/cron/scheduler_announce_delivery_tests.rs b/crates/openhuman-core/src/cron/scheduler_announce_delivery_tests.rsnew file mode 100644index 0000000000..6360f3dbb1--- /dev/null+++ b/crates/openhuman-core/src/cron/scheduler_announce_delivery_tests.rs@@ -0,0 +1,142 @@+use super::*;+use async_trait::async_trait;+use std::sync::Mutex;+use tinychannels_bus::{Channel, ChannelMessage, SendMessage};+use tinyflows_bus::schedule::types::DeliveryStatus;+use tokio::sync::mpsc;++struct AnnounceMockChannel {+ name: String,+ sends: Arc<Mutex<Vec<(String, Option<String>)>>>,+ fail: bool,+}++#[async_trait]+impl Channel for AnnounceMockChannel {+ fn name(&self) -> &str {+ &self.name+ }++ async fn send(&self, message: &SendMessage) -> anyhow::Result<()> {+ self.sends+ .lock()+ .unwrap()+ .push((message.recipient.clone(), message.idempotency_key.clone()));+ if self.fail {+ anyhow::bail!("mock announce send failed");+ }+ Ok(())+ }++ async fn listen(&self, _tx: mpsc::Sender<ChannelMessage>) -> anyhow::Result<()> {+ Ok(())+ }+}++fn install_mock_channel(name: String, fail: bool) -> Arc<Mutex<Vec<(String, Option<String>)>>> {+ let sends = Arc::new(Mutex::new(Vec::new()));+ let channel: Arc<dyn Channel> = Arc::new(AnnounceMockChannel {+ name: name.clone(),+ sends: Arc::clone(&sends),+ fail,+ });+ crate::cron::channel_bridge::register_channel_bridge(+ Arc::new(Mutex::new(std::collections::HashMap::new())),+ Arc::new(std::collections::HashMap::from([(name, channel)])),+ crate::cron::channel_bridge::MAX_HISTORY_MESSAGES,+ );+ sends+}++#[tokio::test]+async fn announce_to_unavailable_channel_is_reported_as_failed() {+ let tmp = TempDir::new().unwrap();+ let config = test_config(&tmp).await;+ let missing_channel = format!("missing-{}", uuid::Uuid::new_v4());+ let mut job = test_job("echo ok");+ job.delivery = DeliveryConfig {+ mode: "announce".into(),+ channel: Some(missing_channel),+ to: Some("target".into()),+ best_effort: false,+ };++ let result = deliver_run(+ &crate::core::runtime::DispatchCtx::ambient(),+ &config,+ &job,+ "run-1",+ "hello",+ true,+ )+ .await;++ assert_eq!(+ result.unwrap(),+ DeliveryStatus::Failed,+ "an announce without a registered channel must not report Delivered"+ );+}++#[tokio::test]+async fn announce_send_failure_is_reported_as_failed() {+ let _bridge_lock = crate::cron::channel_bridge::TEST_BRIDGE_LOCK.lock().await;+ let tmp = TempDir::new().unwrap();+ let config = test_config(&tmp).await;+ let channel = format!("failing-{}", uuid::Uuid::new_v4());+ let sends = install_mock_channel(channel.clone(), true);+ let mut job = test_job("echo ok");+ job.delivery = DeliveryConfig {+ mode: "announce".into(),+ channel: Some(channel),+ to: Some("target".into()),+ best_effort: false,+ };++ let result = deliver_run(+ &crate::core::runtime::DispatchCtx::ambient(),+ &config,+ &job,+ "run-2",+ "hello",+ true,+ )+ .await+ .unwrap();++ assert_eq!(result, DeliveryStatus::Failed);+ assert_eq!(sends.lock().unwrap().len(), 1);+}++#[tokio::test]+async fn announce_success_is_reported_and_uses_a_run_idempotency_key() {+ let _bridge_lock = crate::cron::channel_bridge::TEST_BRIDGE_LOCK.lock().await;+ let tmp = TempDir::new().unwrap();+ let config = test_config(&tmp).await;+ let channel = format!("working-{}", uuid::Uuid::new_v4());+ let sends = install_mock_channel(channel.clone(), false);+ let mut job = test_job("echo ok");+ job.delivery = DeliveryConfig {+ mode: "announce".into(),+ channel: Some(channel),+ to: Some("target".into()),+ best_effort: false,+ };++ let result = deliver_run(+ &crate::core::runtime::DispatchCtx::ambient(),+ &config,+ &job,+ "run-3",+ "hello",+ true,+ )+ .await+ .unwrap();++ assert_eq!(result, DeliveryStatus::Delivered);+ assert_eq!(+ *sends.lock().unwrap(),+ vec![("target".into(), Some(format!("cron:{}:run-3", job.id)))]+ );+}diff --git a/crates/openhuman-core/src/cron/scheduler_classifier_and_delivery_tests.rs b/crates/openhuman-core/src/cron/scheduler_classifier_and_delivery_tests.rsindex d158dec335..714a36b771 100644--- a/crates/openhuman-core/src/cron/scheduler_classifier_and_delivery_tests.rs+++ b/crates/openhuman-core/src/cron/scheduler_classifier_and_delivery_tests.rs@@ -1,55 +1,4 @@use super::*;-use async_trait::async_trait;-use std::sync::{Arc, Mutex};-use tinychannels_bus::{Channel, ChannelMessage, SendMessage};-use tinyflows_bus::schedule::types::DeliveryStatus;-use tokio::sync::mpsc;--struct AnnounceMockChannel {- name: String,- sends: Arc<Mutex<Vec<(String, Option<String>)>>>,- fail: bool,-}--#[async_trait]-impl Channel for AnnounceMockChannel {- fn name(&self) -> &str {- &self.name- }-- async fn send(&self, message: &SendMessage) -> anyhow::Result<()> {- self.sends- .lock()- .unwrap()- .push((message.recipient.clone(), message.idempotency_key.clone()));- if self.fail {- anyhow::bail!("mock announce send failed");- }- Ok(())- }-- async fn listen(&self, _tx: mpsc::Sender<ChannelMessage>) -> anyhow::Result<()> {- Ok(())- }-}--fn install_announce_mock_channel(- name: String,- fail: bool,-) -> Arc<Mutex<Vec<(String, Option<String>)>>> {- let sends = Arc::new(Mutex::new(Vec::new()));- let channel: Arc<dyn Channel> = Arc::new(AnnounceMockChannel {- name: name.clone(),- sends: Arc::clone(&sends),- fail,- });- crate::cron::channel_bridge::register_channel_bridge(- Arc::new(Mutex::new(std::collections::HashMap::new())),- Arc::new(std::collections::HashMap::from([(name, channel)])),- crate::cron::channel_bridge::MAX_HISTORY_MESSAGES,- );- sends-}#[test]fn forbidden_path_argument_skips_flags_and_urls() {@@ -119,99 +68,6 @@ async fn deliver_if_configured_announce_missing_target_errors() {assert!(result.is_err());}-#[tokio::test]-async fn announce_to_unavailable_channel_is_reported_as_failed() {- let tmp = TempDir::new().unwrap();- let config = test_config(&tmp).await;- let missing_channel = format!("missing-{}", uuid::Uuid::new_v4());- let mut job = test_job("echo ok");- job.delivery = DeliveryConfig {- mode: "announce".into(),- channel: Some(missing_channel),- to: Some("target".into()),- best_effort: false,- };-- let result = deliver_run(- &crate::core::runtime::DispatchCtx::ambient(),- &config,- &job,- "run-1",- "hello",- true,- )- .await;-- assert_eq!(- result.unwrap(),- DeliveryStatus::Failed,- "an announce without a registered channel must not report Delivered"- );-}--#[tokio::test]-async fn announce_send_failure_is_reported_as_failed() {- let _bridge_lock = crate::cron::channel_bridge::TEST_BRIDGE_LOCK.lock().await;- let tmp = TempDir::new().unwrap();- let config = test_config(&tmp).await;- let channel = format!("failing-{}", uuid::Uuid::new_v4());- let sends = install_announce_mock_channel(channel.clone(), true);- let mut job = test_job("echo ok");- job.delivery = DeliveryConfig {- mode: "announce".into(),- channel: Some(channel),- to: Some("target".into()),- best_effort: false,- };-- let result = deliver_run(- &crate::core::runtime::DispatchCtx::ambient(),- &config,- &job,- "run-2",- "hello",- true,- )- .await- .unwrap();-- assert_eq!(result, DeliveryStatus::Failed);- assert_eq!(sends.lock().unwrap().len(), 1);-}--#[tokio::test]-async fn announce_success_is_reported_and_uses_a_run_idempotency_key() {- let _bridge_lock = crate::cron::channel_bridge::TEST_BRIDGE_LOCK.lock().await;- let tmp = TempDir::new().unwrap();- let config = test_config(&tmp).await;- let channel = format!("working-{}", uuid::Uuid::new_v4());- let sends = install_announce_mock_channel(channel.clone(), false);- let mut job = test_job("echo ok");- job.delivery = DeliveryConfig {- mode: "announce".into(),- channel: Some(channel),- to: Some("target".into()),- best_effort: false,- };-- let result = deliver_run(- &crate::core::runtime::DispatchCtx::ambient(),- &config,- &job,- "run-3",- "hello",- true,- )- .await- .unwrap();-- assert_eq!(result, DeliveryStatus::Delivered);- assert_eq!(- *sends.lock().unwrap(),- vec![("target".into(), Some(format!("cron:{}:run-3", job.id)))]- );-}-#[tokio::test]async fn deliver_if_configured_proactive_mode_succeeds() {let tmp = TempDir::new().unwrap();diff --git a/crates/openhuman-core/src/cron/scheduler_tests.rs b/crates/openhuman-core/src/cron/scheduler_tests.rsindex f06e88bbe3..1564ea9f83 100644--- a/crates/openhuman-core/src/cron/scheduler_tests.rs+++ b/crates/openhuman-core/src/cron/scheduler_tests.rs@@ -107,6 +107,8 @@ fn next_user_error(#[path = "scheduler_classifier_and_delivery_tests.rs"]mod classifier_and_delivery_tests;+#[path = "scheduler_announce_delivery_tests.rs"]+mod announce_delivery_tests;#[path = "scheduler_dispatch_tests.rs"]mod dispatch_tests;#[path = "scheduler_frequency_tests.rs"]