MCPcopy Create free account
hub / github.com/driangle/taskmd / TestGraphCommand_OutputToFile

Function TestGraphCommand_OutputToFile

apps/cli/internal/cli/graph_test.go:628–667  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

626}
627
628func 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
669func TestGraphCommand_ErrorInvalidRoot(t *testing.T) {
670 tmpDir := createTestTaskFiles(t)

Callers

nothing calls this directly

Calls 3

runGraphFunction · 0.85
ErrorMethod · 0.80
createTestTaskFilesFunction · 0.70

Tested by

no test coverage detected