aboutsummaryrefslogtreecommitdiff
path: root/tests/cli
diff options
context:
space:
mode:
authorakbash <akbash@herdr.dev>2026-08-25 01:44:10 +0300
committerGitHub <noreply@github.com>2026-08-25 01:44:10 +0300
commit0e548bcf72671e6e6e661e90192bcb7f2f442032 (patch)
treebe689fcc2ace48cd6e288998f0bd470307a313a5 /tests/cli
parentcafd9e5dd0e59ecc7551ae066c737f23573460a7 (diff)
fix: report agent explain file errors as json (#3023)
refs #3022 Co-authored-by: akbash-bot <300245827+akbash-bot@users.noreply.github.com>
Diffstat (limited to 'tests/cli')
-rw-r--r--tests/cli/agents.rs29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/cli/agents.rs b/tests/cli/agents.rs
index 3164b802..c3e98f86 100644
--- a/tests/cli/agents.rs
+++ b/tests/cli/agents.rs
@@ -1,5 +1,34 @@
use super::harness::*;
+#[test]
+fn agent_explain_missing_file_reports_json_error() {
+ let base = unique_test_dir();
+ let missing = base.join("missing-screen.txt");
+ let output = run_named_cli(
+ &base.join("config"),
+ &base.join("runtime"),
+ &[
+ "agent",
+ "explain",
+ "--file",
+ missing.to_str().unwrap(),
+ "--agent",
+ "claude",
+ "--json",
+ ],
+ );
+
+ assert_eq!(output.status.code(), Some(1));
+ assert!(output.stdout.is_empty());
+ let error: serde_json::Value = serde_json::from_slice(&output.stderr).unwrap();
+ assert_eq!(error["id"], "cli:agent:explain");
+ assert_eq!(error["error"]["code"], "agent_explain_file_read_failed");
+ assert!(error["error"]["message"]
+ .as_str()
+ .unwrap()
+ .contains(missing.to_str().unwrap()));
+}
+
fn write_delayed_shell_and_fake_pi(
base: &Path,
shell_delay_seconds: &str,