use super::logging_responder::LoggingResponder;
use crate::commands::{CommandResponse, Responder};
use swiftide::chat_completion::ChatMessage;
use uuid::Uuid;
#[test]
fn test_logging_responder_formatting() {
let responder = LoggingResponder::new();
let chat_message = ChatMessage::Assistant(
Some(
r#"Here's a message with "quotes" and \n newlines and a JSON: {"key": "value"}"#
.to_string(),
),
None,
);
responder.agent_message(chat_message);
let uuid = Uuid::new_v4();
let command_response = CommandResponse::BackendMessage(
uuid,
r#"Message with "quotes" and \n newlines"#.to_string(),
);
responder.send(command_response);
responder.system_message(r#"System message with "quotes" and \n newlines"#);
responder.update(r#"Update with "quotes" and \n newlines"#);
let log = responder.get_log();
println!("Log output:\n{log}");
assert!(log.contains(r#"Assistant(Some("Here's a message with "quotes" and "#));
assert!(log.contains(r#"newlines and a JSON: {"key": "value"}")"#));
assert!(log.contains(r"BackendMessage("));
assert!(log.contains(r#", "Message with "quotes" and "#));
assert!(log.contains("newlines"));
assert!(log.contains(r#"System message with "quotes" and "#));
assert!(log.contains("newlines"));
}