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

Function TestReadTool_LargeFile

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

Source from the content-addressed store, hash-verified

226}
227
228func TestReadTool_LargeFile(t *testing.T) {
229 SkipIfShort(t)
230
231 tool, err := NewReadTool(nil)
232 if err != nil {
233 t.Fatalf("Failed to create Read tool: %v", err)
234 }
235
236 helper := NewTestHelper(t)
237 defer helper.CleanupAll()
238
239 // 创建大文件 (1MB)
240 largeContent := strings.Repeat("This is a line for testing large file processing.\n", 1024*64)
241 filePath := helper.CreateTempFile("large.txt", largeContent)
242
243 start := time.Now()
244 input := map[string]any{
245 "file_path": filePath,
246 }
247
248 result := ExecuteToolWithRealFS(t, tool, input)
249 result = AssertToolSuccess(t, result)
250 duration := time.Since(start)
251
252 content := result["content"].(string)
253 if len(content) != len(largeContent) {
254 t.Errorf("Content length mismatch: expected %d, got %d",
255 len(largeContent), len(content))
256 }
257
258 // 性能检查 - 读取1MB文件应该在1秒内完成
259 if duration > time.Second {
260 t.Logf("Warning: Reading 1MB file took %v", duration)
261 }
262}
263
264func TestReadTool_ConcurrentReads(t *testing.T) {
265 tool, err := NewReadTool(nil)

Callers

nothing calls this directly

Calls 7

CleanupAllMethod · 0.95
CreateTempFileMethod · 0.95
SkipIfShortFunction · 0.85
NewReadToolFunction · 0.85
NewTestHelperFunction · 0.85
ExecuteToolWithRealFSFunction · 0.85
AssertToolSuccessFunction · 0.85

Tested by

no test coverage detected