| 189 | |
| 190 | #[tokio::test] |
| 191 | async fn test_edit_replace_all() { |
| 192 | let temp = tempfile::tempdir().unwrap(); |
| 193 | std::fs::write(temp.path().join("test.txt"), "aaa bbb aaa").unwrap(); |
| 194 | |
| 195 | let tool = EditTool; |
| 196 | let ctx = ToolContext::new(temp.path().to_path_buf()); |
| 197 | |
| 198 | let result = tool |
| 199 | .execute( |
| 200 | &serde_json::json!({ |
| 201 | "file_path": "test.txt", |
| 202 | "old_string": "aaa", |
| 203 | "new_string": "ccc", |
| 204 | "replace_all": true |
| 205 | }), |
| 206 | &ctx, |
| 207 | ) |
| 208 | .await |
| 209 | .unwrap(); |
| 210 | |
| 211 | assert!(result.success); |
| 212 | let content = std::fs::read_to_string(temp.path().join("test.txt")).unwrap(); |
| 213 | assert_eq!(content, "ccc bbb ccc"); |
| 214 | } |
| 215 | |
| 216 | #[tokio::test] |
| 217 | async fn test_edit_not_unique() { |