Refactor agent2 tests structure

- Move tests from thread/tests.rs to tests/mod.rs
- Move test_tools from thread/tests/test_tools.rs to tests/test_tools.rs
- Update imports and fix compilation errors in tests
- Fix private field access by using public messages() method
- Add necessary imports for test modules
This commit is contained in:
Nathan Sobo 2025-08-01 22:48:35 -06:00
parent 84d6a0fae9
commit afc8cf6098
3 changed files with 10 additions and 4 deletions

View file

@ -3,4 +3,7 @@ mod templates;
mod thread;
mod tools;
#[cfg(test)]
mod tests;
pub use thread::*;

View file

@ -1,5 +1,6 @@
use super::*;
use client::{proto::language_server_prompt_request, Client, UserStore};
use crate::templates::Templates;
use client::{Client, UserStore};
use fs::FakeFs;
use gpui::{AppContext, Entity, TestAppContext};
use language_model::{
@ -27,7 +28,7 @@ async fn test_echo(cx: &mut TestAppContext) {
.await;
agent.update(cx, |agent, _cx| {
assert_eq!(
agent.messages.last().unwrap().content,
agent.messages().last().unwrap().content,
vec![MessageContent::Text("Hello".to_string())]
);
});
@ -74,7 +75,7 @@ async fn test_basic_tool_calls(cx: &mut TestAppContext) {
);
agent.update(cx, |agent, _cx| {
assert!(agent
.messages
.messages()
.last()
.unwrap()
.content
@ -170,7 +171,7 @@ async fn test_concurrent_tool_calls(cx: &mut TestAppContext) {
}
agent.update(cx, |agent, _cx| {
let last_message = agent.messages.last().unwrap();
let last_message = agent.messages().last().unwrap();
let text = last_message
.content
.iter()

View file

@ -1,4 +1,6 @@
use super::*;
use anyhow::Result;
use gpui::{App, SharedString, Task};
/// A tool that echoes its input
#[derive(JsonSchema, Serialize, Deserialize)]