TestWorkflowStatus_ConsoleRendering tests that WorkflowStatus uses console.RenderStruct correctly
(t *testing.T)
| 296 | |
| 297 | // TestWorkflowStatus_ConsoleRendering tests that WorkflowStatus uses console.RenderStruct correctly |
| 298 | func TestWorkflowStatus_ConsoleRendering(t *testing.T) { |
| 299 | // Create test data |
| 300 | statuses := []WorkflowStatus{ |
| 301 | { |
| 302 | WorkflowListItem: WorkflowListItem{ |
| 303 | Workflow: "test-workflow-1", |
| 304 | EngineID: "copilot", |
| 305 | Compiled: "Yes", |
| 306 | }, |
| 307 | Status: "active", |
| 308 | TimeRemaining: "N/A", |
| 309 | }, |
| 310 | { |
| 311 | WorkflowListItem: WorkflowListItem{ |
| 312 | Workflow: "test-workflow-2", |
| 313 | EngineID: "claude", |
| 314 | Compiled: "No", |
| 315 | }, |
| 316 | Status: "disabled", |
| 317 | TimeRemaining: "2h 30m", |
| 318 | }, |
| 319 | } |
| 320 | |
| 321 | // Render using console.RenderStruct |
| 322 | output := console.RenderStruct(statuses) |
| 323 | |
| 324 | // Verify the output contains table headers from console tags |
| 325 | expectedHeaders := []string{"workflow", "engine", "compiled"} |
| 326 | for _, header := range expectedHeaders { |
| 327 | if !strings.Contains(output, header) { |
| 328 | t.Errorf("Expected output to contain header '%s', got:\n%s", header, output) |
| 329 | } |
| 330 | } |
| 331 | |
| 332 | // Verify hidden headers are absent |
| 333 | hiddenHeaders := []string{"Status", "Time Remaining"} |
| 334 | for _, header := range hiddenHeaders { |
| 335 | if strings.Contains(output, header) { |
| 336 | t.Errorf("Expected output NOT to contain header '%s', got:\n%s", header, output) |
| 337 | } |
| 338 | } |
| 339 | |
| 340 | // Verify the output contains the data values |
| 341 | expectedValues := []string{ |
| 342 | "test-workflow-1", "copilot", "Yes", "active", |
| 343 | "test-workflow-2", "claude", "No", "disabled", "2h 30m", |
| 344 | } |
| 345 | for _, value := range expectedValues { |
| 346 | if !strings.Contains(output, value) { |
| 347 | t.Errorf("Expected output to contain value '%s', got:\n%s", value, output) |
| 348 | } |
| 349 | } |
| 350 | |
| 351 | // Verify it's formatted as a table (contains separators) |
| 352 | if !strings.Contains(output, "-") { |
| 353 | t.Error("Expected table output to contain separator lines") |
| 354 | } |
| 355 | } |
nothing calls this directly
no test coverage detected