chore: turn clippy on for test code (#4817)
This commit is contained in:
@@ -20,6 +20,7 @@ use goose::providers::{
|
||||
enum ProviderType {
|
||||
Azure,
|
||||
OpenAi,
|
||||
#[allow(dead_code)]
|
||||
Anthropic,
|
||||
Bedrock,
|
||||
Databricks,
|
||||
@@ -540,9 +541,7 @@ mod schedule_tool_tests {
|
||||
mod final_output_tool_tests {
|
||||
use super::*;
|
||||
use futures::stream;
|
||||
use goose::agents::final_output_tool::{
|
||||
FINAL_OUTPUT_CONTINUATION_MESSAGE, FINAL_OUTPUT_TOOL_NAME,
|
||||
};
|
||||
use goose::agents::final_output_tool::FINAL_OUTPUT_TOOL_NAME;
|
||||
use goose::conversation::Conversation;
|
||||
use goose::providers::base::MessageStream;
|
||||
use goose::recipe::Response;
|
||||
@@ -1151,7 +1150,7 @@ mod max_turns_tests {
|
||||
}
|
||||
|
||||
assert!(
|
||||
responses.len() >= 1,
|
||||
!responses.is_empty(),
|
||||
"Expected at least 1 response, got {}",
|
||||
responses.len()
|
||||
);
|
||||
|
||||
@@ -431,7 +431,7 @@ mod tests {
|
||||
assert!(recipe.extensions.is_some());
|
||||
let extensions = recipe.extensions.unwrap();
|
||||
// At minimum we should get the full config (stdio), shortname may not resolve
|
||||
assert!(extensions.len() >= 1 && extensions.len() <= 2);
|
||||
assert!(!extensions.is_empty() && extensions.len() <= 2);
|
||||
// The last one should always be the stdio config we provided
|
||||
if let Some(last) = extensions.last() {
|
||||
match last {
|
||||
|
||||
@@ -57,9 +57,7 @@ mod execution_tests {
|
||||
async fn test_session_limit() {
|
||||
let manager = AgentManager::new(Some(3)).await.unwrap();
|
||||
|
||||
let sessions: Vec<_> = (0..3)
|
||||
.map(|i| String::from(format!("session-{}", i)))
|
||||
.collect();
|
||||
let sessions: Vec<_> = (0..3).map(|i| format!("session-{}", i)).collect();
|
||||
|
||||
for session in &sessions {
|
||||
manager
|
||||
|
||||
@@ -156,6 +156,7 @@ async fn test_replayed_session(
|
||||
|
||||
let extension_manager = ExtensionManager::new();
|
||||
|
||||
#[allow(clippy::redundant_closure_call)]
|
||||
let result = (async || -> Result<(), Box<dyn std::error::Error>> {
|
||||
extension_manager.add_extension(extension_config).await?;
|
||||
|
||||
|
||||
@@ -29,10 +29,17 @@ pub struct ConfigurableMockScheduler {
|
||||
running_jobs: Arc<Mutex<HashSet<String>>>,
|
||||
call_log: Arc<Mutex<Vec<String>>>,
|
||||
behaviors: Arc<Mutex<HashMap<String, MockBehavior>>>,
|
||||
#[allow(clippy::type_complexity)]
|
||||
sessions_data: Arc<Mutex<HashMap<String, Vec<(String, SessionMetadata)>>>>,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
impl Default for ConfigurableMockScheduler {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl ConfigurableMockScheduler {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
@@ -44,36 +51,6 @@ impl ConfigurableMockScheduler {
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn with_behavior(self, method: &str, behavior: MockBehavior) -> Self {
|
||||
self.behaviors
|
||||
.lock()
|
||||
.await
|
||||
.insert(method.to_string(), behavior);
|
||||
self
|
||||
}
|
||||
|
||||
pub async fn with_existing_job(self, job: ScheduledJob) -> Self {
|
||||
self.jobs.lock().await.insert(job.id.clone(), job);
|
||||
self
|
||||
}
|
||||
|
||||
pub async fn with_running_job(self, job_id: &str) -> Self {
|
||||
self.running_jobs.lock().await.insert(job_id.to_string());
|
||||
self
|
||||
}
|
||||
|
||||
pub async fn with_sessions_data(
|
||||
self,
|
||||
job_id: &str,
|
||||
sessions: Vec<(String, SessionMetadata)>,
|
||||
) -> Self {
|
||||
self.sessions_data
|
||||
.lock()
|
||||
.await
|
||||
.insert(job_id.to_string(), sessions);
|
||||
self
|
||||
}
|
||||
|
||||
pub async fn get_calls(&self) -> Vec<String> {
|
||||
self.call_log.lock().await.clone()
|
||||
}
|
||||
@@ -337,6 +314,12 @@ pub struct ScheduleToolTestBuilder {
|
||||
scheduler: Arc<ConfigurableMockScheduler>,
|
||||
}
|
||||
|
||||
impl Default for ScheduleToolTestBuilder {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl ScheduleToolTestBuilder {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
|
||||
@@ -11,7 +11,6 @@ use goose::session::storage::SessionMetadata;
|
||||
use rmcp::model::Tool;
|
||||
use std::sync::Arc;
|
||||
use tempfile::TempDir;
|
||||
use tokio;
|
||||
use uuid::Uuid;
|
||||
|
||||
// Mock provider implementation for testing
|
||||
@@ -298,7 +297,7 @@ async fn test_todo_clear_removes_from_session() {
|
||||
.unwrap();
|
||||
|
||||
// Consume the stream
|
||||
while let Some(_) = stream.next().await {}
|
||||
while (stream.next().await).is_some() {}
|
||||
|
||||
// With mock provider, the TODO won't actually be cleared via tool calls
|
||||
// but we can verify the structure is correct
|
||||
@@ -463,9 +462,12 @@ async fn test_todo_update_preserves_other_metadata() {
|
||||
|
||||
// Set initial metadata with various fields
|
||||
let mut metadata = SessionMetadata::default();
|
||||
metadata.message_count = 5;
|
||||
metadata.description = "Test session".to_string();
|
||||
metadata.total_tokens = Some(1000);
|
||||
#[allow(clippy::field_reassign_with_default)]
|
||||
{
|
||||
metadata.message_count = 5;
|
||||
metadata.description = "Test session".to_string();
|
||||
metadata.total_tokens = Some(1000);
|
||||
}
|
||||
let todo_state = TodoState::new("Initial TODO".to_string());
|
||||
todo_state
|
||||
.to_extension_data(&mut metadata.extension_data)
|
||||
|
||||
Reference in New Issue
Block a user