| 109 | |
| 110 | #[tokio::test] |
| 111 | async fn test_write_new_file() { |
| 112 | let temp = tempfile::tempdir().unwrap(); |
| 113 | let tool = WriteTool; |
| 114 | let ctx = ToolContext::new(temp.path().to_path_buf()); |
| 115 | |
| 116 | let result = tool |
| 117 | .execute( |
| 118 | &serde_json::json!({"file_path": "new.txt", "content": "hello world"}), |
| 119 | &ctx, |
| 120 | ) |
| 121 | .await |
| 122 | .unwrap(); |
| 123 | |
| 124 | assert!(result.success); |
| 125 | let content = std::fs::read_to_string(temp.path().join("new.txt")).unwrap(); |
| 126 | assert_eq!(content, "hello world"); |
| 127 | } |
| 128 | |
| 129 | #[tokio::test] |
| 130 | async fn test_write_creates_parent_dirs() { |