From d94c0c6d54c2e2b3e5ad7a95943bdb402bbed886 Mon Sep 17 00:00:00 2001 From: Salman Mohammed Date: Thu, 14 Nov 2024 09:51:03 -0500 Subject: [PATCH] fix bash change directory tests --- crates/goose/src/developer.rs | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/crates/goose/src/developer.rs b/crates/goose/src/developer.rs index a59eca1b..8ee06313 100644 --- a/crates/goose/src/developer.rs +++ b/crates/goose/src/developer.rs @@ -557,15 +557,29 @@ mod tests { } #[tokio::test] - async fn test_bash_change_directory() { + async fn test_bash_change_directory_no_effect() { let system = get_system().await; let tool_call = ToolCall::new("bash", json!({ "working_dir": ".", "command": "pwd" })); let result = system.call(tool_call).await.unwrap(); - assert!(result["result"] - .as_str() - .unwrap() - .contains("Changed directory to")); + // since working_dir is ., we DON'T expect the result to contain "Changed directory" + assert!(!result.as_str().unwrap().contains("Changed directory to")); + } + + #[tokio::test] + async fn test_bash_change_directory_success() { + let system = get_system().await; + let temp_dir = tempfile::Builder::new() + .prefix("test_temp_") + .tempdir_in(".") + .unwrap(); + + let tool_call = ToolCall::new( + "bash", + json!({ "working_dir": temp_dir.path().display().to_string(), "command": "pwd" }), + ); + let result = system.call(tool_call).await.unwrap(); + assert!(result.as_str().unwrap().contains("Changed directory to")); } #[tokio::test]