MCPcopy Index your code
hub / github.com/AI45Lab/Code / test_edit_replace_all

Function test_edit_replace_all

core/src/tools/builtin/edit.rs:191–214  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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() {

Callers

nothing calls this directly

Calls 3

writeFunction · 0.85
pathMethod · 0.80
executeMethod · 0.45

Tested by

no test coverage detected