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

Function TestTracks_TableHeaderWithScopes

apps/cli/internal/cli/tracks_test.go:411–456  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

409}
410
411func TestTracks_TableHeaderWithScopes(t *testing.T) {
412 resetTracksFlags()
413 tracksFormat = "table"
414
415 result := &tracks.Result{
416 Tracks: []tracks.Track{
417 {
418 ID: 1,
419 Scopes: []string{"scope-a", "scope-b"},
420 Tasks: []tracks.TrackTask{{ID: "001", Title: "Task one", Priority: "high"}},
421 },
422 {
423 ID: 2,
424 Scopes: []string{},
425 Tasks: []tracks.TrackTask{{ID: "002", Title: "Task two", Priority: "medium"}},
426 },
427 },
428 }
429
430 oldStdout := os.Stdout
431 r, w, _ := os.Pipe()
432 os.Stdout = w
433
434 err := outputTracksTable(result)
435
436 w.Close()
437 os.Stdout = oldStdout
438
439 var buf bytes.Buffer
440 buf.ReadFrom(r)
441 output := buf.String()
442
443 if err != nil {
444 t.Fatalf("outputTracksTable failed: %v", err)
445 }
446
447 if !strings.Contains(output, "Track 1 (scope-a, scope-b):") {
448 t.Errorf("Expected 'Track 1 (scope-a, scope-b):', got:\n%s", output)
449 }
450 if !strings.Contains(output, "Track 2:") {
451 t.Errorf("Expected 'Track 2:' without parentheses, got:\n%s", output)
452 }
453 if strings.Contains(output, "Track 2 ()") {
454 t.Error("Track with no scopes should not have empty parentheses")
455 }
456}
457
458func TestTracks_ScopeFlag_JSON(t *testing.T) {
459 tmpDir := createTracksTestTaskFiles(t)

Callers

nothing calls this directly

Calls 3

resetTracksFlagsFunction · 0.85
outputTracksTableFunction · 0.85
ErrorMethod · 0.80

Tested by

no test coverage detected