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

Function TestReadTool_BinaryFile

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

Source from the content-addressed store, hash-verified

346}
347
348func 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
389func TestReadTool_SpecialFiles(t *testing.T) {
390 t.Skip("Skipping: requires special file detection/blocking implementation (reading /dev/random causes infinite blocking)")

Callers

nothing calls this directly

Calls 7

CleanupAllMethod · 0.95
NewReadToolFunction · 0.85
NewTestHelperFunction · 0.85
ExecuteToolWithRealFSFunction · 0.85
AssertToolSuccessFunction · 0.85
ErrorMethod · 0.65
JoinMethod · 0.45

Tested by

no test coverage detected