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

Function TestToASCII_WithFormatter

sdk/go/graph/graph_test.go:370–441  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

368}
369
370func TestToASCII_WithFormatter(t *testing.T) {
371 tasks := []*model.Task{
372 {
373 ID: "T1",
374 Title: "Root",
375 Status: model.StatusCompleted,
376 Dependencies: []string{},
377 },
378 {
379 ID: "T2",
380 Title: "Child",
381 Status: model.StatusInProgress,
382 Dependencies: []string{"T1"},
383 },
384 }
385
386 g := NewGraph(tasks)
387
388 f := &ASCIIFormatter{
389 FormatID: func(id string) string {
390 return "<ID:" + id + ">"
391 },
392 FormatTitle: func(title, status string) string {
393 return "<T:" + title + ":" + status + ">"
394 },
395 FormatStatusIndicator: func(indicator, _ string) string {
396 return "<S:" + strings.TrimSpace(indicator) + ">"
397 },
398 FormatConnector: func(connector string) string {
399 return "<C:" + connector + ">"
400 },
401 FormatReference: func(text string) string {
402 return "<R:" + text + ">"
403 },
404 }
405
406 output := g.ToASCII("T1", true, f)
407
408 if !strings.Contains(output, "<ID:T1>") {
409 t.Errorf("Expected formatted ID for T1, got:\n%s", output)
410 }
411 if !strings.Contains(output, "<ID:T2>") {
412 t.Errorf("Expected formatted ID for T2, got:\n%s", output)
413 }
414 if !strings.Contains(output, "<T:Root:completed>") {
415 t.Errorf("Expected formatted title for Root, got:\n%s", output)
416 }
417 if !strings.Contains(output, "<T:Child:in-progress>") {
418 t.Errorf("Expected formatted title for Child, got:\n%s", output)
419 }
420 if !strings.Contains(output, "<S:✓>") {
421 t.Errorf("Expected formatted status indicator for completed, got:\n%s", output)
422 }
423 if !strings.Contains(output, "<S:⋯>") {
424 t.Errorf("Expected formatted status indicator for in-progress, got:\n%s", output)
425 }
426 // Test connector formatting with multiple children.
427 tasksMulti := []*model.Task{

Callers

nothing calls this directly

Calls 2

ToASCIIMethod · 0.95
NewGraphFunction · 0.85

Tested by

no test coverage detected