diff options
| author | salmonik <salmonik@tuta.io> | 2026-11-15 17:16:08 +0100 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-11-15 17:16:08 +0100 |
| commit | 14e56289391ea95b493c2a20c87f8d88047aa051 (patch) | |
| tree | d0acf1cc35369688d92c781e31fb7afc30c38b7a /tests/cli.rs | |
| parent | 0.5.3: session locking, UTF-8 and size guards for edit, correct character widths (diff) | |
| download | agent686-14e56289391ea95b493c2a20c87f8d88047aa051.tar.gz agent686-14e56289391ea95b493c2a20c87f8d88047aa051.zip | |
0.6.0: transcript viewer, turn summary, yolo floor, model/version records
- --show renders a session without locking it
- status line summarises writes, commands and denials per turn
- sessions record harness version; model switches are appended and listed
- --yolo refuses $HOME and / unless AGENT686_ALLOW_HOME=1
Diffstat (limited to '')
| -rw-r--r-- | tests/cli.rs | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/tests/cli.rs b/tests/cli.rs index 04fd637..6c041fb 100644 --- a/tests/cli.rs +++ b/tests/cli.rs | |||
| @@ -76,3 +76,72 @@ fn unknown_flags_go_to_stderr_with_usage() { | |||
| 76 | assert!(stderr.contains("unknown flag"), "{stderr}"); | 76 | assert!(stderr.contains("unknown flag"), "{stderr}"); |
| 77 | assert!(stderr.contains("USAGE"), "{stderr}"); | 77 | assert!(stderr.contains("USAGE"), "{stderr}"); |
| 78 | } | 78 | } |
| 79 | |||
| 80 | #[test] | ||
| 81 | fn yolo_is_refused_in_the_home_directory() { | ||
| 82 | let home = temp_home("yolo"); | ||
| 83 | let output = agent() | ||
| 84 | .current_dir(&home) | ||
| 85 | .env("HOME", &home) | ||
| 86 | .env("OPENCODE_API_KEY", "test") | ||
| 87 | .arg("--yolo") | ||
| 88 | .stdin(std::process::Stdio::null()) | ||
| 89 | .output() | ||
| 90 | .unwrap(); | ||
| 91 | |||
| 92 | assert_eq!(output.status.code(), Some(2), "{output:?}"); | ||
| 93 | let stderr = String::from_utf8_lossy(&output.stderr); | ||
| 94 | assert!(stderr.contains("refusing --yolo"), "{stderr}"); | ||
| 95 | assert!(stderr.contains("AGENT686_ALLOW_HOME"), "{stderr}"); | ||
| 96 | } | ||
| 97 | |||
| 98 | #[test] | ||
| 99 | fn yolo_in_home_can_be_forced() { | ||
| 100 | let home = temp_home("yolo-force"); | ||
| 101 | let output = agent() | ||
| 102 | .current_dir(&home) | ||
| 103 | .env("HOME", &home) | ||
| 104 | .env("OPENCODE_API_KEY", "test") | ||
| 105 | .env("AGENT686_ALLOW_HOME", "1") | ||
| 106 | .args(["--yolo", "--session", "forced"]) | ||
| 107 | .stdin(std::process::Stdio::null()) | ||
| 108 | .output() | ||
| 109 | .unwrap(); | ||
| 110 | |||
| 111 | assert_eq!(output.status.code(), Some(0), "{output:?}"); | ||
| 112 | } | ||
| 113 | |||
| 114 | #[test] | ||
| 115 | fn show_renders_a_transcript() { | ||
| 116 | use serde_json::json; | ||
| 117 | |||
| 118 | let home = temp_home("show"); | ||
| 119 | let sessions = home.join(".local/share/agent686/sessions"); | ||
| 120 | fs::create_dir_all(&sessions).unwrap(); | ||
| 121 | |||
| 122 | let lines = [ | ||
| 123 | json!({"t":"header","session":"demo","model":"m","cwd":"/tmp","version":"0.0.0", | ||
| 124 | "system":{"role":"system","content":"sys"}}), | ||
| 125 | json!({"t":"msg","role":"user","content":"do the thing"}), | ||
| 126 | json!({"t":"msg","role":"assistant","content":"on it","_reasoning":"thinking about it", | ||
| 127 | "tool_calls":[{"id":"c1","type":"function", | ||
| 128 | "function":{"name":"read","arguments":"{\"path\":\"a\"}"}}]}), | ||
| 129 | json!({"t":"msg","role":"tool","tool_call_id":"c1","content":"line one\nline two"}), | ||
| 130 | ]; | ||
| 131 | let body: String = lines.iter().map(|line| format!("{line}\n")).collect(); | ||
| 132 | fs::write(sessions.join("demo.jsonl"), body).unwrap(); | ||
| 133 | |||
| 134 | let output = agent() | ||
| 135 | .env("HOME", &home) | ||
| 136 | .args(["--show", "demo"]) | ||
| 137 | .output() | ||
| 138 | .unwrap(); | ||
| 139 | |||
| 140 | assert!(output.status.success(), "{output:?}"); | ||
| 141 | let stdout = String::from_utf8_lossy(&output.stdout); | ||
| 142 | assert!(stdout.contains("do the thing"), "{stdout}"); | ||
| 143 | assert!(stdout.contains("● read"), "{stdout}"); | ||
| 144 | assert!(stdout.contains("line one"), "{stdout}"); | ||
| 145 | assert!(stdout.contains("on it"), "{stdout}"); | ||
| 146 | assert!(stdout.contains("thinking about it"), "{stdout}"); | ||
| 147 | } | ||
