(t *testing.T)
| 626 | } |
| 627 | |
| 628 | func TestGraphCommand_OutputToFile(t *testing.T) { |
| 629 | tmpDir := createTestTaskFiles(t) |
| 630 | outFile := filepath.Join(t.TempDir(), "graph.json") |
| 631 | |
| 632 | // Reset flags |
| 633 | graphFormat = "json" |
| 634 | graphExcludeStatus = []string{} |
| 635 | graphRoot = "" |
| 636 | graphFocus = "" |
| 637 | graphUpstream = false |
| 638 | graphDownstream = false |
| 639 | graphOut = outFile |
| 640 | |
| 641 | // Run command |
| 642 | err := runGraph(graphCmd, []string{tmpDir}) |
| 643 | if err != nil { |
| 644 | t.Fatalf("runGraph failed: %v", err) |
| 645 | } |
| 646 | |
| 647 | // Verify file was created |
| 648 | if _, err := os.Stat(outFile); os.IsNotExist(err) { |
| 649 | t.Fatal("Expected output file to be created") |
| 650 | } |
| 651 | |
| 652 | // Read and verify content |
| 653 | content, err := os.ReadFile(outFile) |
| 654 | if err != nil { |
| 655 | t.Fatalf("Failed to read output file: %v", err) |
| 656 | } |
| 657 | |
| 658 | var result map[string]any |
| 659 | err = json.Unmarshal(content, &result) |
| 660 | if err != nil { |
| 661 | t.Fatalf("Failed to parse JSON from file: %v", err) |
| 662 | } |
| 663 | |
| 664 | if result["nodes"] == nil { |
| 665 | t.Error("Expected output file to contain nodes") |
| 666 | } |
| 667 | } |
| 668 | |
| 669 | func TestGraphCommand_ErrorInvalidRoot(t *testing.T) { |
| 670 | tmpDir := createTestTaskFiles(t) |
nothing calls this directly
no test coverage detected