Skip to content

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

chore: files changed crates/openhuman-core/src/cron/store.rs,crates/openhuman-core/src/cron/store_te

Steven Enamakele015f2699c67
diff --git a/crates/openhuman-core/src/cron/store.rs b/crates/openhuman-core/src/cron/store.rs
index f21fbc04c4..1e44cdeb63 100644
--- a/crates/openhuman-core/src/cron/store.rs
+++ b/crates/openhuman-core/src/cron/store.rs
@@ -303,34 +303,6 @@ pub fn list_runs(config: &Config, job_id: &str, limit: usize) -> Result<Vec<Cron
)
}
-/// Moves a job's next run to `at`, which no production path can do directly
-/// (a patch reschedules from the schedule, not to a given instant). Writes the
-/// three forms the store keeps of the instant, so the due-job query sees it.
-#[cfg(test)]
-pub(crate) fn force_next_run_for_test(
- config: &Config,
- job_id: &str,
- at: DateTime<Utc>,
-) -> Result<()> {
- use tinystoragedrivers::Precondition;
- let opened = crate::storage::local::open("cron::store", &config.workspace_dir)?;
- let docs = std::sync::Arc::clone(opened.scoped()?.documents());
- let job_id = job_id.to_string();
- crate::storage::block_on_anyhow(async move {
- let stored = docs
- .get("cron_jobs", &job_id)
- .await?
- .ok_or_else(|| anyhow::anyhow!("no job {job_id}"))?;
- let mut doc = stored.doc;
- doc["next_run"] = serde_json::json!(at.to_rfc3339());
- doc["next_run_ms"] = serde_json::json!(at.timestamp_millis());
- doc["next_run_ns"] = serde_json::json!(at.timestamp_nanos_opt().unwrap_or(i64::MAX));
- docs.put("cron_jobs", &job_id, doc, Precondition::None)
- .await?;
- Ok(())
- })
-}
-
#[cfg(test)]
#[path = "store_tests.rs"]
-mod tests;
+pub(crate) mod tests;
diff --git a/crates/openhuman-core/src/cron/store_tests.rs b/crates/openhuman-core/src/cron/store_tests.rs
index 7a0e0fea0e..c9f8ce9958 100644
--- a/crates/openhuman-core/src/cron/store_tests.rs
+++ b/crates/openhuman-core/src/cron/store_tests.rs
@@ -6,6 +6,32 @@ use super::*;
use chrono::Duration as ChronoDuration;
use tempfile::TempDir;
+/// Move one scheduled row into the past for scheduler tests. The document
+/// representation belongs to the module store; this helper is test-only.
+pub(crate) fn force_next_run_for_test(
+ config: &Config,
+ job_id: &str,
+ at: DateTime<Utc>,
+) -> Result<()> {
+ use tinystoragedrivers::Precondition;
+ let opened = crate::storage::local::open("cron::store", &config.workspace_dir)?;
+ let docs = std::sync::Arc::clone(opened.scoped()?.documents());
+ let job_id = job_id.to_string();
+ crate::storage::block_on_anyhow(async move {
+ let stored = docs
+ .get("cron_jobs", &job_id)
+ .await?
+ .ok_or_else(|| anyhow::anyhow!("no job {job_id}"))?;
+ let mut doc = stored.doc;
+ doc["next_run"] = serde_json::json!(at.to_rfc3339());
+ doc["next_run_ms"] = serde_json::json!(at.timestamp_millis());
+ doc["next_run_ns"] = serde_json::json!(at.timestamp_nanos_opt().unwrap_or(i64::MAX));
+ docs.put("cron_jobs", &job_id, doc, Precondition::None)
+ .await?;
+ Ok(())
+ })
+}
+
fn test_config(tmp: &TempDir) -> Config {
let config = Config {
workspace_dir: tmp.path().join("workspace"),