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

Function TestEditTool_NonExistentFile

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

Source from the content-addressed store, hash-verified

177}
178
179func TestEditTool_NonExistentFile(t *testing.T) {
180 tool, err := NewEditTool(nil)
181 if err != nil {
182 t.Fatalf("Failed to create Edit tool: %v", err)
183 }
184
185 input := map[string]any{
186 "file_path": "/nonexistent/file.txt",
187 "old_string": "old content",
188 "new_string": "new content",
189 }
190
191 result := ExecuteToolWithInput(t, tool, input)
192
193 // 应该返回文件不存在的错误
194 errMsg := AssertToolError(t, result)
195 if !strings.Contains(strings.ToLower(errMsg), "file") &&
196 !strings.Contains(strings.ToLower(errMsg), "not found") &&
197 !strings.Contains(strings.ToLower(errMsg), "no such file") {
198 t.Errorf("Expected file not found error, got: %s", errMsg)
199 }
200}
201
202func TestEditTool_SameString(t *testing.T) {
203 if testing.Short() {

Callers

nothing calls this directly

Calls 3

NewEditToolFunction · 0.85
ExecuteToolWithInputFunction · 0.85
AssertToolErrorFunction · 0.85

Tested by

no test coverage detected