| 333 | |
| 334 | #[tokio::test] |
| 335 | async fn test_patch_tool() { |
| 336 | let temp = tempfile::tempdir().unwrap(); |
| 337 | std::fs::write(temp.path().join("test.txt"), "line1\nold_line\nline3\n").unwrap(); |
| 338 | |
| 339 | let tool = PatchTool; |
| 340 | let ctx = ToolContext::new(temp.path().to_path_buf()); |
| 341 | |
| 342 | let result = tool |
| 343 | .execute( |
| 344 | &serde_json::json!({ |
| 345 | "file_path": "test.txt", |
| 346 | "diff": "@@ -1,3 +1,3 @@\n line1\n-old_line\n+new_line\n line3" |
| 347 | }), |
| 348 | &ctx, |
| 349 | ) |
| 350 | .await |
| 351 | .unwrap(); |
| 352 | |
| 353 | assert!(result.success); |
| 354 | let content = std::fs::read_to_string(temp.path().join("test.txt")).unwrap(); |
| 355 | assert!(content.contains("new_line")); |
| 356 | assert!(!content.contains("old_line")); |
| 357 | } |
| 358 | |
| 359 | #[test] |
| 360 | fn test_parse_hunks_no_header() { |