(t *testing.T)
| 346 | } |
| 347 | |
| 348 | func TestReadTool_BinaryFile(t *testing.T) { |
| 349 | t.Skip("Skipping: binary file type detection not implemented") |
| 350 | tool, err := NewReadTool(nil) |
| 351 | if err != nil { |
| 352 | t.Fatalf("Failed to create Read tool: %v", err) |
| 353 | } |
| 354 | |
| 355 | helper := NewTestHelper(t) |
| 356 | defer helper.CleanupAll() |
| 357 | |
| 358 | // 创建二进制文件 |
| 359 | binaryData := []byte{0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A} // PNG header |
| 360 | binaryFile := filepath.Join(helper.TmpDir, "binary.png") |
| 361 | if err := os.WriteFile(binaryFile, binaryData, 0644); err != nil { |
| 362 | t.Fatalf("Failed to create binary file: %v", err) |
| 363 | } |
| 364 | |
| 365 | input := map[string]any{ |
| 366 | "file_path": binaryFile, |
| 367 | } |
| 368 | |
| 369 | result := ExecuteToolWithRealFS(t, tool, input) |
| 370 | result = AssertToolSuccess(t, result) |
| 371 | |
| 372 | // 验证文件类型检测 |
| 373 | if fileType, exists := result["file_type"]; !exists { |
| 374 | t.Error("Result should contain 'file_type' field") |
| 375 | } else if fileTypeStr, ok := fileType.(string); !ok { |
| 376 | t.Error("file_type should be a string") |
| 377 | } else if fileTypeStr != "binary" { |
| 378 | t.Errorf("Expected binary file type, got: %s", fileTypeStr) |
| 379 | } |
| 380 | |
| 381 | // 验证内容 - 应该被编码或处理 |
| 382 | if content, exists := result["content"]; !exists { |
| 383 | t.Error("Result should contain 'content' field") |
| 384 | } else if _, ok := content.(string); !ok { |
| 385 | t.Error("Content should be a string") |
| 386 | } |
| 387 | } |
| 388 | |
| 389 | func TestReadTool_SpecialFiles(t *testing.T) { |
| 390 | t.Skip("Skipping: requires special file detection/blocking implementation (reading /dev/random causes infinite blocking)") |
nothing calls this directly
no test coverage detected