MCPcopy Create free account
hub / github.com/astercloud/aster / TestEditTool_SameString

Function TestEditTool_SameString

pkg/tools/builtin/edit_test.go:202–230  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

200}
201
202func TestEditTool_SameString(t *testing.T) {
203 if testing.Short() {
204 t.Skip("Skipping file modification test in short mode")
205 }
206
207 tool, err := NewEditTool(nil)
208 if err != nil {
209 t.Fatalf("Failed to create Edit tool: %v", err)
210 }
211
212 // 创建测试文件
213 helper := NewTestHelper(t)
214 testFile := helper.CreateTempFile("test.txt", "Hello World")
215 defer helper.CleanupAll()
216
217 input := map[string]any{
218 "file_path": testFile,
219 "old_string": "Hello World",
220 "new_string": "Hello World", // 相同的内容
221 }
222
223 result := ExecuteToolWithRealFS(t, tool, input)
224 result = AssertToolSuccess(t, result)
225
226 // 应该显示没有修改
227 if changes, exists := result["changes_made"]; !exists || changes.(int) != 0 {
228 t.Error("Should indicate 0 changes were made")
229 }
230}
231
232func BenchmarkEditTool_SimpleEdit(b *testing.B) {
233 if testing.Short() {

Callers

nothing calls this directly

Calls 7

CreateTempFileMethod · 0.95
CleanupAllMethod · 0.95
NewEditToolFunction · 0.85
NewTestHelperFunction · 0.85
ExecuteToolWithRealFSFunction · 0.85
AssertToolSuccessFunction · 0.85
ErrorMethod · 0.65

Tested by

no test coverage detected