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(openhuman-embed): add shared test helpers for profile tests
Steven Enamakel7d9e46f99da1
diff --git a/crates/openhuman-embed/tests/common/mod.rs b/crates/openhuman-embed/tests/common/mod.rsindex 599b5c2aab..356d9b286b 100644--- a/crates/openhuman-embed/tests/common/mod.rs+++ b/crates/openhuman-embed/tests/common/mod.rs@@ -384,3 +384,11 @@ impl wiremock::Respond for EchoCompletion {}}}++/// Sleep until the wall clock passes `instant` (plus a beat for the store's+/// millisecond ordering). Scheduled jobs now run on the tinyflows module's own+/// clock, which a test cannot move, so a job due "later" is waited for.+pub async fn wait_until(instant: chrono::DateTime<chrono::Utc>) {+ let remaining = (instant - chrono::Utc::now()).to_std().unwrap_or_default();+ tokio::time::sleep(remaining + std::time::Duration::from_millis(250)).await;+}diff --git a/crates/openhuman-embed/tests/profile_cron_sweep.rs b/crates/openhuman-embed/tests/profile_cron_sweep.rsindex 7ebc76d6ee..7bdfc202c4 100644--- a/crates/openhuman-embed/tests/profile_cron_sweep.rs+++ b/crates/openhuman-embed/tests/profile_cron_sweep.rs@@ -119,8 +119,11 @@ async fn scenario() {// Nothing is due yet; two sweepers race for each job once it is.assert_eq!(runtime.sweep_cron_at(chrono::Utc::now()).await.ran, 0);- let later = chrono::Utc::now() + chrono::Duration::hours(1);- let (a, b) = tokio::join!(runtime.sweep_cron_at(later), runtime.sweep_cron_at(later));+ common::wait_until(soon).await;+ let (a, b) = tokio::join!(+ runtime.sweep_cron_at(chrono::Utc::now()),+ runtime.sweep_cron_at(chrono::Utc::now())+ );assert_eq!(a.ran + b.ran, 3, "each occurrence runs once: {a:?} {b:?}");let mut delivered: Vec<_> = recorder@@ -174,6 +177,6 @@ async fn scenario() {// One-shot jobs are gone; a later sweep finds nothing.tokio::time::sleep(Duration::from_millis(50)).await;- assert_eq!(runtime.sweep_cron_at(later).await.ran, 0);+ assert_eq!(runtime.sweep_cron_at(chrono::Utc::now()).await.ran, 0);assert_eq!(recorder.0.lock().unwrap().len(), 2);}diff --git a/crates/openhuman-embed/tests/profile_operator_tools.rs b/crates/openhuman-embed/tests/profile_operator_tools.rsindex f84f3566d2..736a0fa18a 100644--- a/crates/openhuman-embed/tests/profile_operator_tools.rs+++ b/crates/openhuman-embed/tests/profile_operator_tools.rs@@ -104,7 +104,7 @@ fn operator_named_cron_and_time_tools_run_on_a_direct_provider_within_the_iteratasync fn scenario() {let (managed, chat) = (MockServer::start().await, MockServer::start().await);- let fire_at = chrono::Utc::now() + chrono::Duration::seconds(30);+ let fire_at = chrono::Utc::now() + chrono::Duration::seconds(6);Mock::given(method("POST")).and(path_regex(r"/v1/chat/completions$")).and(header("authorization", "Bearer operator-chat-key"))@@ -161,8 +161,8 @@ async fn scenario() {// An agent job made through the tool binds to this thread and fires.handle.chat("t1", "schedule it").await.unwrap();- let later = chrono::Utc::now() + chrono::Duration::hours(1);- assert_eq!(runtime.sweep_cron_at(later).await.ran, 1);+ common::wait_until(fire_at).await;+ assert_eq!(runtime.sweep_cron_at(chrono::Utc::now()).await.ran, 1);tokio::time::timeout(Duration::from_secs(30), async {while recorder.0.lock().unwrap().is_empty() {tokio::time::sleep(Duration::from_millis(20)).await;@@ -193,7 +193,7 @@ async fn scenario() {.any(|r| String::from_utf8_lossy(&r.body).contains("only agent cron jobs are allowed")),"the refusal reaches the model");- assert_eq!(runtime.sweep_cron_at(later).await.ran, 0);+ assert_eq!(runtime.sweep_cron_at(chrono::Utc::now()).await.ran, 0);// A model that never stops calling tools is cut off at the operator's cap:// the harness stops at CAP model calls and the turn's recovery adds a fewdiff --git a/crates/openhuman-embed/tests/profile_turn_serialization.rs b/crates/openhuman-embed/tests/profile_turn_serialization.rsindex ad6b54bfbd..7050ca56a5 100644--- a/crates/openhuman-embed/tests/profile_turn_serialization.rs+++ b/crates/openhuman-embed/tests/profile_turn_serialization.rs@@ -136,8 +136,8 @@ async fn scenario() {assert!(!chat.is_finished(), "alice's turn is still running");// The sweep runs Alice's job, but only once her chat turn is over.- let later = chrono::Utc::now() + chrono::Duration::hours(1);- let report = runtime.sweep_cron_at(later).await;+ common::wait_until(soon).await;+ let report = runtime.sweep_cron_at(chrono::Utc::now()).await;assert_eq!(report.ran, 1,"the occurrence is deferred, not skipped: {report:?}"