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

Function TestReadTool_EmptyFile

pkg/tools/builtin/read_test.go:121–153  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

119}
120
121func TestReadTool_EmptyFile(t *testing.T) {
122 tool, err := NewReadTool(nil)
123 if err != nil {
124 t.Fatalf("Failed to create Read tool: %v", err)
125 }
126
127 helper := NewTestHelper(t)
128 defer helper.CleanupAll()
129
130 // 创建空文件
131 filePath := helper.CreateTempFile("empty.txt", "")
132
133 input := map[string]any{
134 "file_path": filePath,
135 }
136
137 result := ExecuteToolWithRealFS(t, tool, input)
138 result = AssertToolSuccess(t, result)
139
140 if content, exists := result["content"]; !exists {
141 t.Error("Result should contain 'content' field")
142 } else if contentStr, ok := content.(string); !ok {
143 t.Error("Content should be a string")
144 } else if contentStr != "" {
145 t.Errorf("Expected empty content, got %q", contentStr)
146 }
147
148 if size, exists := result["file_size"]; !exists {
149 t.Error("Result should contain 'size' field")
150 } else if sizeInt, ok := size.(int); !ok || sizeInt != 0 {
151 t.Errorf("Size should be 0, got %v", size)
152 }
153}
154
155func TestReadTool_FileNotFound(t *testing.T) {
156 tool, err := NewReadTool(nil)

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected