diff options
Diffstat (limited to 'tests/cli.rs')
| -rw-r--r-- | tests/cli.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/cli.rs b/tests/cli.rs index 6c041fb..5a4c03f 100644 --- a/tests/cli.rs +++ b/tests/cli.rs | |||
| @@ -145,3 +145,28 @@ fn show_renders_a_transcript() { | |||
| 145 | assert!(stdout.contains("on it"), "{stdout}"); | 145 | assert!(stdout.contains("on it"), "{stdout}"); |
| 146 | assert!(stdout.contains("thinking about it"), "{stdout}"); | 146 | assert!(stdout.contains("thinking about it"), "{stdout}"); |
| 147 | } | 147 | } |
| 148 | |||
| 149 | #[test] | ||
| 150 | fn a_flag_shaped_value_is_rejected_unless_attached() { | ||
| 151 | let output = agent().args(["--session", "--list"]).output().unwrap(); | ||
| 152 | assert_eq!(output.status.code(), Some(2)); | ||
| 153 | assert!( | ||
| 154 | String::from_utf8_lossy(&output.stderr).contains("needs a value"), | ||
| 155 | "{:?}", | ||
| 156 | String::from_utf8_lossy(&output.stderr) | ||
| 157 | ); | ||
| 158 | |||
| 159 | // The attached form works and creates a session whose id starts with `-`. | ||
| 160 | let home = temp_home("dash-session"); | ||
| 161 | let output = agent() | ||
| 162 | .env("HOME", &home) | ||
| 163 | .env("OPENCODE_API_KEY", "test") | ||
| 164 | .args(["--session=-abc", "--base-url", "http://127.0.0.1:9/v1"]) | ||
| 165 | .stdin(std::process::Stdio::null()) | ||
| 166 | .output() | ||
| 167 | .unwrap(); | ||
| 168 | assert_eq!(output.status.code(), Some(0), "{output:?}"); | ||
| 169 | assert!(home | ||
| 170 | .join(".local/share/agent686/sessions/-abc.jsonl") | ||
| 171 | .exists()); | ||
| 172 | } | ||
