Skip to content

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

test(cli): cover cross-process reads through a storage url

Steven Enamakel1df1bcfe9c4a
diff --git a/tests/cli_storage_url_e2e.rs b/tests/cli_storage_url_e2e.rs
index f07825cb3d..6db2c8642c 100644
--- a/tests/cli_storage_url_e2e.rs
+++ b/tests/cli_storage_url_e2e.rs
@@ -47,3 +47,60 @@ fn a_one_shot_command_opens_a_valid_storage_url_and_help_does_not_need_one() {
);
assert!(nested.status.success(), "nested help never opens storage");
}
+
+/// Runs `args` as a one-shot in its own workspace (so the classic on-disk
+/// layout cannot be what two runs share) against `url`.
+fn one_shot(url: &str, args: &[&str]) -> (std::process::Output, tempfile::TempDir) {
+ let workspace = tempfile::tempdir().unwrap();
+ let output = core(workspace.path(), Some(url), args);
+ (output, workspace)
+}
+
+#[test]
+fn a_second_process_reads_what_a_one_shot_wrote_to_the_backend() {
+ let data = tempfile::tempdir().unwrap();
+ let candidates = [
+ format!("sqlite://{}", data.path().join("shared.db").display()),
+ format!("file://{}", data.path().join("shared-files").display()),
+ ];
+ for url in &candidates {
+ let (added, _first) = one_shot(
+ url,
+ &[
+ "cron",
+ "add",
+ "--name",
+ "storage-probe",
+ "--schedule",
+ r#"{"kind":"every","every_ms":3600000}"#,
+ "--command",
+ "echo probe",
+ ],
+ );
+ let stderr = String::from_utf8_lossy(&added.stderr);
+ if !added.status.success() {
+ // This build carries neither driver for the URL: nothing to share.
+ assert!(
+ stderr.contains("storage-sqlite") || stderr.contains("storage-file"),
+ "cron add failed for a reason other than a missing driver: {stderr}"
+ );
+ continue;
+ }
+
+ // A different workspace: only the backend can hold the job.
+ let (listed, _second) = one_shot(url, &["cron", "list"]);
+ assert!(listed.status.success(), "{}", String::from_utf8_lossy(&listed.stderr));
+ let stdout = String::from_utf8_lossy(&listed.stdout);
+ assert!(stdout.contains("storage-probe"), "second process sees the job: {stdout}");
+
+ // And without the URL the same fresh workspace has nothing.
+ let workspace = tempfile::tempdir().unwrap();
+ let classic = core(workspace.path(), None, &["cron", "list"]);
+ assert!(
+ !String::from_utf8_lossy(&classic.stdout).contains("storage-probe"),
+ "the job lives in the backend, not in files"
+ );
+ return;
+ }
+ eprintln!("skipped: no storage driver compiled in (enable storage-sqlite or storage-file)");
+}