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:
parent
84d6a0fae9
commit
afc8cf6098
3 changed files with 10 additions and 4 deletions
|
@ -3,4 +3,7 @@ mod templates;
|
||||||
mod thread;
|
mod thread;
|
||||||
mod tools;
|
mod tools;
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests;
|
||||||
|
|
||||||
pub use thread::*;
|
pub use thread::*;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
use super::*;
|
use super::*;
|
||||||
use client::{proto::language_server_prompt_request, Client, UserStore};
|
use crate::templates::Templates;
|
||||||
|
use client::{Client, UserStore};
|
||||||
use fs::FakeFs;
|
use fs::FakeFs;
|
||||||
use gpui::{AppContext, Entity, TestAppContext};
|
use gpui::{AppContext, Entity, TestAppContext};
|
||||||
use language_model::{
|
use language_model::{
|
||||||
|
@ -27,7 +28,7 @@ async fn test_echo(cx: &mut TestAppContext) {
|
||||||
.await;
|
.await;
|
||||||
agent.update(cx, |agent, _cx| {
|
agent.update(cx, |agent, _cx| {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
agent.messages.last().unwrap().content,
|
agent.messages().last().unwrap().content,
|
||||||
vec![MessageContent::Text("Hello".to_string())]
|
vec![MessageContent::Text("Hello".to_string())]
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -74,7 +75,7 @@ async fn test_basic_tool_calls(cx: &mut TestAppContext) {
|
||||||
);
|
);
|
||||||
agent.update(cx, |agent, _cx| {
|
agent.update(cx, |agent, _cx| {
|
||||||
assert!(agent
|
assert!(agent
|
||||||
.messages
|
.messages()
|
||||||
.last()
|
.last()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.content
|
.content
|
||||||
|
@ -170,7 +171,7 @@ async fn test_concurrent_tool_calls(cx: &mut TestAppContext) {
|
||||||
}
|
}
|
||||||
|
|
||||||
agent.update(cx, |agent, _cx| {
|
agent.update(cx, |agent, _cx| {
|
||||||
let last_message = agent.messages.last().unwrap();
|
let last_message = agent.messages().last().unwrap();
|
||||||
let text = last_message
|
let text = last_message
|
||||||
.content
|
.content
|
||||||
.iter()
|
.iter()
|
|
@ -1,4 +1,6 @@
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use anyhow::Result;
|
||||||
|
use gpui::{App, SharedString, Task};
|
||||||
|
|
||||||
/// A tool that echoes its input
|
/// A tool that echoes its input
|
||||||
#[derive(JsonSchema, Serialize, Deserialize)]
|
#[derive(JsonSchema, Serialize, Deserialize)]
|
Loading…
Add table
Add a link
Reference in a new issue