(t *testing.T)
| 353 | } |
| 354 | |
| 355 | func TestGraphCommand_Mermaid_Format(t *testing.T) { |
| 356 | tmpDir := createTestTaskFiles(t) |
| 357 | |
| 358 | // Reset flags |
| 359 | graphFormat = "mermaid" |
| 360 | graphExcludeStatus = []string{} |
| 361 | graphAll = false |
| 362 | graphRoot = "" |
| 363 | graphFocus = "" |
| 364 | graphUpstream = false |
| 365 | graphDownstream = false |
| 366 | graphOut = "" |
| 367 | |
| 368 | // Capture stdout |
| 369 | oldStdout := os.Stdout |
| 370 | r, w, _ := os.Pipe() |
| 371 | os.Stdout = w |
| 372 | |
| 373 | // Run command |
| 374 | err := runGraph(graphCmd, []string{tmpDir}) |
| 375 | if err != nil { |
| 376 | t.Fatalf("runGraph failed: %v", err) |
| 377 | } |
| 378 | |
| 379 | // Restore stdout |
| 380 | w.Close() |
| 381 | os.Stdout = oldStdout |
| 382 | |
| 383 | // Read output |
| 384 | var buf bytes.Buffer |
| 385 | buf.ReadFrom(r) |
| 386 | output := buf.String() |
| 387 | |
| 388 | // Verify mermaid syntax |
| 389 | if !strings.Contains(output, "graph TD") { |
| 390 | t.Error("Expected mermaid output to start with 'graph TD'") |
| 391 | } |
| 392 | |
| 393 | // Verify nodes are defined |
| 394 | if !strings.Contains(output, "001[") { |
| 395 | t.Error("Expected node definition for task 001") |
| 396 | } |
| 397 | |
| 398 | // Verify edges |
| 399 | if !strings.Contains(output, "-->") { |
| 400 | t.Error("Expected mermaid output to contain edge arrows") |
| 401 | } |
| 402 | |
| 403 | // Verify styles are included |
| 404 | if !strings.Contains(output, "classDef") { |
| 405 | t.Error("Expected mermaid output to contain style definitions") |
| 406 | } |
| 407 | } |
| 408 | |
| 409 | func TestGraphCommand_Mermaid_WithFocus(t *testing.T) { |
| 410 | tmpDir := createTestTaskFiles(t) |
nothing calls this directly
no test coverage detected