diff options
| author | salmonik <salmon@2137697.xyz> | 2026-11-23 20:36:22 +0100 |
|---|---|---|
| committer | salmonik <salmon@2137697.xyz> | 2026-11-23 20:36:22 +0100 |
| commit | e803aa488c3a95193d3e3ae358b640c299f8f121 (patch) | |
| tree | 0af80401445159ca40a8ab3d7bbf39094ab5db77 /tests/sessions.rs | |
| parent | 0.12.1: accept `command` as an alias for `cmd` in bash (diff) | |
| download | agent686-e803aa488c3a95193d3e3ae358b640c299f8f121.tar.gz agent686-e803aa488c3a95193d3e3ae358b640c299f8f121.zip | |
License
Diffstat (limited to '')
| -rw-r--r-- | tests/sessions.rs | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/tests/sessions.rs b/tests/sessions.rs index 4f8ebd5..e382673 100644 --- a/tests/sessions.rs +++ b/tests/sessions.rs | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | /* | ||
| 2 | * This file is part of agent686 | ||
| 3 | * Copyright (C) 2026 Salmonik <salmon@2137697.xyz> | ||
| 4 | * SPDX-License-Identifier: GPL-3.0-or-later | ||
| 5 | * https://git.2137697.xyz/agent686 | ||
| 6 | */ | ||
| 7 | |||
| 1 | use std::fs; | 8 | use std::fs; |
| 2 | use std::path::PathBuf; | 9 | use std::path::PathBuf; |
| 3 | use std::process::Command; | 10 | use std::process::Command; |
| @@ -92,7 +99,9 @@ fn a_session_cannot_be_open_twice() { | |||
| 92 | let system = json!({ "role": "system", "content": "x" }); | 99 | let system = json!({ "role": "system", "content": "x" }); |
| 93 | let first = Session::create_as("locked".into(), "m", &system).unwrap(); | 100 | let first = Session::create_as("locked".into(), "m", &system).unwrap(); |
| 94 | 101 | ||
| 95 | let error = Session::open("locked").err().expect("second open must fail"); | 102 | let error = Session::open("locked") |
| 103 | .err() | ||
| 104 | .expect("second open must fail"); | ||
| 96 | assert!(error.contains("already open"), "{error}"); | 105 | assert!(error.contains("already open"), "{error}"); |
| 97 | 106 | ||
| 98 | drop(first); | 107 | drop(first); |
| @@ -127,8 +136,10 @@ fn a_torn_utf8_line_does_not_brick_a_session() { | |||
| 127 | br#"{"t":"header","session":"torn","model":"m","cwd":"/tmp","system":{"role":"system","content":"s"}} | 136 | br#"{"t":"header","session":"torn","model":"m","cwd":"/tmp","system":{"role":"system","content":"s"}} |
| 128 | "#, | 137 | "#, |
| 129 | ); | 138 | ); |
| 130 | raw.extend_from_slice(br#"{"t":"msg","role":"user","content":"hello"} | 139 | raw.extend_from_slice( |
| 131 | "#); | 140 | br#"{"t":"msg","role":"user","content":"hello"} |
| 141 | "#, | ||
| 142 | ); | ||
| 132 | // A killed write that split a multi-byte character. | 143 | // A killed write that split a multi-byte character. |
| 133 | raw.extend_from_slice(b"{\"t\":\"msg\",\"role\":\"user\",\"content\":\"caf\xc3\"}\n"); | 144 | raw.extend_from_slice(b"{\"t\":\"msg\",\"role\":\"user\",\"content\":\"caf\xc3\"}\n"); |
| 134 | fs::write(sessions.join("torn.jsonl"), raw).unwrap(); | 145 | fs::write(sessions.join("torn.jsonl"), raw).unwrap(); |
| @@ -156,7 +167,10 @@ fn last_reply_prefers_content_and_falls_back_to_reasoning() { | |||
| 156 | ) | 167 | ) |
| 157 | .unwrap(); | 168 | .unwrap(); |
| 158 | session | 169 | session |
| 159 | .append(&json!({ "role": "assistant", "content": null }), Some("only thinking")) | 170 | .append( |
| 171 | &json!({ "role": "assistant", "content": null }), | ||
| 172 | Some("only thinking"), | ||
| 173 | ) | ||
| 160 | .unwrap(); | 174 | .unwrap(); |
| 161 | 175 | ||
| 162 | drop(session); | 176 | drop(session); |
| @@ -168,7 +182,10 @@ fn last_reply_prefers_content_and_falls_back_to_reasoning() { | |||
| 168 | // With no content anywhere, reasoning is the fallback. | 182 | // With no content anywhere, reasoning is the fallback. |
| 169 | let mut session = Session::create_as("reasoning-only".into(), "m", &system).unwrap(); | 183 | let mut session = Session::create_as("reasoning-only".into(), "m", &system).unwrap(); |
| 170 | session | 184 | session |
| 171 | .append(&json!({ "role": "assistant", "content": null }), Some("thoughts")) | 185 | .append( |
| 186 | &json!({ "role": "assistant", "content": null }), | ||
| 187 | Some("thoughts"), | ||
| 188 | ) | ||
| 172 | .unwrap(); | 189 | .unwrap(); |
| 173 | drop(session); | 190 | drop(session); |
| 174 | let (opened, _system, _messages) = Session::open("reasoning-only").unwrap(); | 191 | let (opened, _system, _messages) = Session::open("reasoning-only").unwrap(); |
