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

Function TestReadTool_ConcurrentReads

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

Source from the content-addressed store, hash-verified

262}
263
264func TestReadTool_ConcurrentReads(t *testing.T) {
265 tool, err := NewReadTool(nil)
266 if err != nil {
267 t.Fatalf("Failed to create Read tool: %v", err)
268 }
269
270 helper := NewTestHelper(t)
271 defer helper.CleanupAll()
272
273 // 创建测试文件
274 testContent := "Concurrent test content"
275 filePath := helper.CreateTempFile("concurrent.txt", testContent)
276
277 concurrency := 10
278 result := RunConcurrentTest(concurrency, func() error {
279 input := map[string]any{
280 "file_path": filePath,
281 }
282 result := ExecuteToolWithRealFS(t, tool, input)
283 if !result["ok"].(bool) {
284 return errors.New("Tool execution failed")
285 }
286 return nil
287 })
288
289 if result.ErrorCount > 0 {
290 t.Errorf("Concurrent reads failed: %d errors out of %d attempts",
291 result.ErrorCount, concurrency)
292 for _, err := range result.Errors {
293 t.Logf("Error: %v", err)
294 }
295 }
296
297 t.Logf("Concurrent reads completed: %d success, %d errors in %v",
298 result.SuccessCount, result.ErrorCount, result.Duration)
299}
300
301func TestReadTool_DirectoryTraversal(t *testing.T) {
302 t.Skip("Skipping: directory traversal protection not fully implemented")

Callers

nothing calls this directly

Calls 6

CleanupAllMethod · 0.95
CreateTempFileMethod · 0.95
NewReadToolFunction · 0.85
NewTestHelperFunction · 0.85
RunConcurrentTestFunction · 0.85
ExecuteToolWithRealFSFunction · 0.85

Tested by

no test coverage detected