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

Function TestGraphCommand_Mermaid_Format

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

Source from the content-addressed store, hash-verified

353}
354
355func 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
409func TestGraphCommand_Mermaid_WithFocus(t *testing.T) {
410 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