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

Function TestWriteTool_OverwriteExisting

pkg/tools/builtin/write_test.go:59–82  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

57}
58
59func TestWriteTool_OverwriteExisting(t *testing.T) {
60 tool, err := NewWriteTool(nil)
61 if err != nil {
62 t.Fatalf("Failed to create Write tool: %v", err)
63 }
64
65 helper := NewTestHelper(t)
66 defer helper.CleanupAll()
67
68 // 先创建一个文件
69 filePath := helper.CreateTempFile("existing.txt", "Original content")
70
71 newContent := "Overwritten content"
72 input := map[string]any{
73 "file_path": filePath,
74 "content": newContent,
75 }
76
77 result := ExecuteToolWithRealFS(t, tool, input)
78 _ = AssertToolSuccess(t, result)
79
80 // 验证文件被覆盖
81 AssertFileContent(t, filePath, newContent)
82}
83
84func TestWriteTool_AppendMode(t *testing.T) {
85 tool, err := NewWriteTool(nil)

Callers

nothing calls this directly

Calls 7

CleanupAllMethod · 0.95
CreateTempFileMethod · 0.95
NewWriteToolFunction · 0.85
NewTestHelperFunction · 0.85
ExecuteToolWithRealFSFunction · 0.85
AssertToolSuccessFunction · 0.85
AssertFileContentFunction · 0.85

Tested by

no test coverage detected