| 164 | |
| 165 | #[tokio::test] |
| 166 | async fn test_edit_single_replace() { |
| 167 | let temp = tempfile::tempdir().unwrap(); |
| 168 | std::fs::write(temp.path().join("test.txt"), "hello world").unwrap(); |
| 169 | |
| 170 | let tool = EditTool; |
| 171 | let ctx = ToolContext::new(temp.path().to_path_buf()); |
| 172 | |
| 173 | let result = tool |
| 174 | .execute( |
| 175 | &serde_json::json!({ |
| 176 | "file_path": "test.txt", |
| 177 | "old_string": "hello", |
| 178 | "new_string": "goodbye" |
| 179 | }), |
| 180 | &ctx, |
| 181 | ) |
| 182 | .await |
| 183 | .unwrap(); |
| 184 | |
| 185 | assert!(result.success); |
| 186 | let content = std::fs::read_to_string(temp.path().join("test.txt")).unwrap(); |
| 187 | assert_eq!(content, "goodbye world"); |
| 188 | } |
| 189 | |
| 190 | #[tokio::test] |
| 191 | async fn test_edit_replace_all() { |