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

Function test_edit_single_replace

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

writeFunction · 0.85
pathMethod · 0.80
executeMethod · 0.45

Tested by

no test coverage detected