Skip to content

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

test(cron): add coverage for job builder, ops, and add tool

Steven Enamakel959b9772b583
diff --git a/crates/openhuman-core/src/cron/job_builder_tests.rs b/crates/openhuman-core/src/cron/job_builder_tests.rs
index cde5b8d5b8..e85c97777e 100644
--- a/crates/openhuman-core/src/cron/job_builder_tests.rs
+++ b/crates/openhuman-core/src/cron/job_builder_tests.rs
@@ -88,7 +88,7 @@ fn origin_delivery_or_current_target_without_an_origin_is_an_error() {
let tmp = TempDir::new().unwrap();
let cfg = config(&tmp);
let mut i = input();
- i.delivery = Some(default_delivery(Some(&web())));
+ i.delivery = Some(validation::default_delivery(Some(&web())));
assert!(create_agent_job(&cfg, i, None)
.unwrap_err()
.contains("origin"));
@@ -122,9 +122,9 @@ fn announce_to_origin_reply_target_skips_allowed_users() {
mention_only: false,
});
// Chat id 42 is not in allowed_users (a username), but it is the asker.
- assert!(validate_delivery(&cfg, &announce("telegram", "42"), Some(&channel())).is_ok());
+ assert!(validate_delivery_for_config(&cfg, &announce("telegram", "42"), Some(&channel())).is_ok());
// Without the origin, or for another target, the allowlist still applies.
- assert!(validate_delivery(&cfg, &announce("telegram", "42"), None).is_err());
- assert!(validate_delivery(&cfg, &announce("telegram", "99"), Some(&channel())).is_err());
- assert!(validate_delivery(&cfg, &announce("discord", "42"), Some(&channel())).is_err());
+ assert!(validate_delivery_for_config(&cfg, &announce("telegram", "42"), None).is_err());
+ assert!(validate_delivery_for_config(&cfg, &announce("telegram", "99"), Some(&channel())).is_err());
+ assert!(validate_delivery_for_config(&cfg, &announce("discord", "42"), Some(&channel())).is_err());
}
diff --git a/crates/openhuman-core/src/cron/ops_tests.rs b/crates/openhuman-core/src/cron/ops_tests.rs
index 9d3599dff2..44194d59c8 100644
--- a/crates/openhuman-core/src/cron/ops_tests.rs
+++ b/crates/openhuman-core/src/cron/ops_tests.rs
@@ -196,61 +196,6 @@ fn update_rejects_expression_for_non_cron_schedule() {
.contains("Cannot update expression/tz on a non-cron schedule"));
}
-// ── parse_delay ─────────────────────────────────────────────────
-
-#[test]
-fn parse_delay_accepts_seconds_minutes_hours_days() {
- assert_eq!(
- parse_human_delay("5s").unwrap(),
- chrono::Duration::seconds(5)
- );
- assert_eq!(
- parse_human_delay("10m").unwrap(),
- chrono::Duration::minutes(10)
- );
- assert_eq!(parse_human_delay("2h").unwrap(), chrono::Duration::hours(2));
- assert_eq!(parse_human_delay("3d").unwrap(), chrono::Duration::days(3));
-}
-
-#[test]
-fn parse_delay_defaults_to_minutes_when_no_unit() {
- assert_eq!(
- parse_human_delay("15").unwrap(),
- chrono::Duration::minutes(15)
- );
-}
-
-#[test]
-fn parse_delay_trims_whitespace() {
- assert_eq!(
- parse_human_delay(" 7m ").unwrap(),
- chrono::Duration::minutes(7)
- );
-}
-
-#[test]
-fn parse_delay_rejects_empty_input() {
- let err = parse_human_delay("").unwrap_err();
- assert!(err.to_string().contains("delay must not be empty"));
- let err = parse_human_delay(" ").unwrap_err();
- assert!(err.to_string().contains("delay must not be empty"));
-}
-
-#[test]
-fn parse_delay_rejects_unsupported_unit() {
- let err = parse_human_delay("5x").unwrap_err();
- assert!(err.to_string().contains("unsupported delay unit"));
- // Multi-char unit not matched in the parse branch either.
- let err = parse_human_delay("5wk").unwrap_err();
- assert!(err.to_string().contains("unsupported delay unit"));
-}
-
-#[test]
-fn parse_delay_rejects_non_numeric_prefix() {
- // No ascii-digit prefix at all → empty num, parse() fails.
- assert!(parse_human_delay("abc").is_err());
-}
-
// ── add_once ────────────────────────────────────────────────────
#[test]
diff --git a/crates/openhuman-core/src/cron/tools/add_tests.rs b/crates/openhuman-core/src/cron/tools/add_tests.rs
index 96f4e5d53e..047c9d620f 100644
--- a/crates/openhuman-core/src/cron/tools/add_tests.rs
+++ b/crates/openhuman-core/src/cron/tools/add_tests.rs
@@ -1,6 +1,5 @@
use super::*;
use crate::config::Config;
-use crate::cron::job_builder::validate_delivery;
use crate::security::AutonomyLevel;
use tempfile::TempDir;
use tinyflows_schedule::types::ActiveHours;
@@ -339,43 +338,6 @@ async fn agent_job_announce_missing_target_rejected() {
assert!(result.output().contains("delivery.to is required"));
}
-#[test]
-fn validate_delivery_skips_proactive_and_none_modes() {
- let tmp = TempDir::new().unwrap();
- let cfg = cfg_with_telegram(&tmp, vec!["alice".into()]);
-
- let proactive = DeliveryConfig {
- mode: "proactive".into(),
- channel: None,
- to: None,
- best_effort: true,
- };
- assert!(validate_delivery(&cfg, &proactive, None).is_ok());
-
- let none = DeliveryConfig {
- mode: "none".into(),
- channel: None,
- to: None,
- best_effort: true,
- };
- assert!(validate_delivery(&cfg, &none, None).is_ok());
-}
-
-#[test]
-fn validate_delivery_announce_web_is_a_no_op() {
- // "web" doesn't have an allowed_users gate; announce to web is
- // a degenerate but valid configuration (in-app explicit).
- let tmp = TempDir::new().unwrap();
- let cfg = test_config_sync(&tmp);
- let cfg_unused = DeliveryConfig {
- mode: "announce".into(),
- channel: Some("web".into()),
- to: Some("any".into()),
- best_effort: true,
- };
- assert!(validate_delivery(&cfg, &cfg_unused, None).is_ok());
-}
-
// ── GHSA-f46p-6vf9-64mm: approval gate must fire for cron_add ────
#[test]