Skip to content

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

test(cli): register cli_storage_url_e2e test target

Steven Enamakel2613a233b2a5
diff --git a/crates/openhuman-cli/Cargo.toml b/crates/openhuman-cli/Cargo.toml
index 0935c1d4f9..36489a8ade 100644
--- a/crates/openhuman-cli/Cargo.toml
+++ b/crates/openhuman-cli/Cargo.toml
@@ -187,6 +187,10 @@ path = "../../tests/cli_model_overrides_e2e.rs"
name = "cli_sigpipe"
path = "../../tests/cli_sigpipe.rs"
+[[test]]
+name = "cli_storage_url_e2e"
+path = "../../tests/cli_storage_url_e2e.rs"
+
[[test]]
name = "saas_mode_e2e"
path = "../../tests/saas_mode_e2e.rs"
diff --git a/tests/cli_storage_url_e2e.rs b/tests/cli_storage_url_e2e.rs
new file mode 100644
index 0000000000..6979314c20
--- /dev/null
+++ b/tests/cli_storage_url_e2e.rs
@@ -0,0 +1,42 @@
+//! One-shot `openhuman-core` subcommands honor the configured storage URL
+//! (`OPENHUMAN_STORAGE_URL`) the way the server does, instead of reading the
+//! classic on-disk layout. The `storage` domain's URL rule is exercised
+//! through the real binary.
+
+use std::process::Command;
+
+fn core(workspace: &std::path::Path, url: Option<&str>, args: &[&str]) -> std::process::Output {
+ let mut cmd = Command::new(env!("CARGO_BIN_EXE_openhuman-core"));
+ cmd.args(args)
+ .env("HOME", workspace)
+ .env("USERPROFILE", workspace)
+ .env("OPENHUMAN_WORKSPACE", workspace)
+ .env_remove("OPENHUMAN_STORAGE_URL");
+ if let Some(url) = url {
+ cmd.env("OPENHUMAN_STORAGE_URL", url);
+ }
+ cmd.output().expect("run openhuman-core")
+}
+
+#[test]
+fn a_one_shot_command_refuses_a_storage_url_it_cannot_open() {
+ let tmp = tempfile::tempdir().unwrap();
+ let output = core(tmp.path(), Some("nonsense://nowhere"), &["cron", "list"]);
+ assert!(!output.status.success(), "a bad URL must fail the command");
+ let stderr = String::from_utf8_lossy(&output.stderr);
+ assert!(stderr.contains("storage"), "{stderr}");
+}
+
+#[test]
+fn a_one_shot_command_opens_a_valid_storage_url_and_help_does_not_need_one() {
+ let tmp = tempfile::tempdir().unwrap();
+ let output = core(tmp.path(), Some("memory"), &["cron", "list"]);
+ let stderr = String::from_utf8_lossy(&output.stderr);
+ assert!(
+ !stderr.contains("opening the configured storage backend"),
+ "{stderr}"
+ );
+ // Help never opens the backend, even a bad one.
+ let help = core(tmp.path(), Some("nonsense://nowhere"), &["--help"]);
+ assert!(help.status.success());
+}