(t *testing.T)
| 119 | } |
| 120 | |
| 121 | func TestReadTool_EmptyFile(t *testing.T) { |
| 122 | tool, err := NewReadTool(nil) |
| 123 | if err != nil { |
| 124 | t.Fatalf("Failed to create Read tool: %v", err) |
| 125 | } |
| 126 | |
| 127 | helper := NewTestHelper(t) |
| 128 | defer helper.CleanupAll() |
| 129 | |
| 130 | // 创建空文件 |
| 131 | filePath := helper.CreateTempFile("empty.txt", "") |
| 132 | |
| 133 | input := map[string]any{ |
| 134 | "file_path": filePath, |
| 135 | } |
| 136 | |
| 137 | result := ExecuteToolWithRealFS(t, tool, input) |
| 138 | result = AssertToolSuccess(t, result) |
| 139 | |
| 140 | if content, exists := result["content"]; !exists { |
| 141 | t.Error("Result should contain 'content' field") |
| 142 | } else if contentStr, ok := content.(string); !ok { |
| 143 | t.Error("Content should be a string") |
| 144 | } else if contentStr != "" { |
| 145 | t.Errorf("Expected empty content, got %q", contentStr) |
| 146 | } |
| 147 | |
| 148 | if size, exists := result["file_size"]; !exists { |
| 149 | t.Error("Result should contain 'size' field") |
| 150 | } else if sizeInt, ok := size.(int); !ok || sizeInt != 0 { |
| 151 | t.Errorf("Size should be 0, got %v", size) |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | func TestReadTool_FileNotFound(t *testing.T) { |
| 156 | tool, err := NewReadTool(nil) |
nothing calls this directly
no test coverage detected