(t *testing.T)
| 226 | } |
| 227 | |
| 228 | func 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 | |
| 264 | func TestReadTool_ConcurrentReads(t *testing.T) { |
| 265 | tool, err := NewReadTool(nil) |
nothing calls this directly
no test coverage detected