From e803aa488c3a95193d3e3ae358b640c299f8f121 Mon Sep 17 00:00:00 2001 From: salmonik Date: Mon, 23 Nov 2026 20:36:22 +0100 Subject: License --- tests/loop.rs | 50 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 14 deletions(-) (limited to 'tests/loop.rs') diff --git a/tests/loop.rs b/tests/loop.rs index 73592f0..06e477c 100644 --- a/tests/loop.rs +++ b/tests/loop.rs @@ -1,3 +1,10 @@ +/* + * This file is part of agent686 + * Copyright (C) 2026 Salmonik + * SPDX-License-Identifier: GPL-3.0-or-later + * https://git.2137697.xyz/agent686 + */ + use std::fs; use std::io::{BufRead, BufReader, Read, Write}; use std::net::TcpListener; @@ -16,9 +23,7 @@ use agent686::session::Session; use agent686::ui::Approver; fn sse(body: &str) -> String { - format!( - "HTTP/1.1 200 OK\r\nContent-Type: text/event-stream\r\nConnection: close\r\n\r\n{body}" - ) + format!("HTTP/1.1 200 OK\r\nContent-Type: text/event-stream\r\nConnection: close\r\n\r\n{body}") } /// Serves one canned SSE response per connection, in order. @@ -197,16 +202,19 @@ fn a_denied_tool_call_is_returned_as_data() { assert!(!target.exists()); assert_eq!(history[3]["role"], "tool"); - assert!( - history[3]["content"] - .as_str() - .unwrap() - .contains("denied by the user") - ); + assert!(history[3]["content"] + .as_str() + .unwrap() + .contains("denied by the user")); assert_eq!(history[4]["content"], "understood"); } -fn tool_call(index: usize, id: &str, name: &str, arguments: serde_json::Value) -> serde_json::Value { +fn tool_call( + index: usize, + id: &str, + name: &str, + arguments: serde_json::Value, +) -> serde_json::Value { json!({ "index": index, "id": id, @@ -283,7 +291,12 @@ fn aborting_between_tool_calls_answers_every_call() { let answered: Vec = history .iter() .filter(|message| message.get("role").and_then(|r| r.as_str()) == Some("tool")) - .filter_map(|message| message.get("tool_call_id").and_then(|id| id.as_str()).map(|s| s.to_string())) + .filter_map(|message| { + message + .get("tool_call_id") + .and_then(|id| id.as_str()) + .map(|s| s.to_string()) + }) .collect(); assert_eq!(answered, vec!["call_a", "call_b", "call_c"], "{answered:?}"); @@ -410,7 +423,10 @@ fn an_empty_bash_call_is_never_approved() { let result = history[3]["content"].as_str().unwrap(); assert!(result.contains("`cmd` is present but empty"), "{result}"); - assert!(!result.contains("denied"), "must not reach an approval prompt: {result}"); + assert!( + !result.contains("denied"), + "must not reach an approval prompt: {result}" + ); } #[test] @@ -525,8 +541,14 @@ fn a_wrong_argument_key_names_both_keys() { .expect("the turn should survive a wrong key"); let result = history[3]["content"].as_str().unwrap(); - assert!(result.contains("`shell`"), "should name what arrived: {result}"); - assert!(result.contains("`cmd`"), "should name what was expected: {result}"); + assert!( + result.contains("`shell`"), + "should name what arrived: {result}" + ); + assert!( + result.contains("`cmd`"), + "should name what was expected: {result}" + ); assert!(!result.contains("denied"), "{result}"); } -- cgit v1.2.3