diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-26 22:11:15 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-26 22:11:15 +0200 |
| commit | c8108deb77f1872e6a55925d5abf9c0ae12813c6 (patch) | |
| tree | e6c0ae91926f0cf68c7dfb89ce46ab1d8facf933 /internal/askcli/formatter_test.go | |
| parent | c9d96d4c1918881f771165e97e71de49917d4181 (diff) | |
ask: align list header columns for task da6d3d36
Diffstat (limited to 'internal/askcli/formatter_test.go')
| -rw-r--r-- | internal/askcli/formatter_test.go | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/internal/askcli/formatter_test.go b/internal/askcli/formatter_test.go index 50d6ae3..adb1e6e 100644 --- a/internal/askcli/formatter_test.go +++ b/internal/askcli/formatter_test.go @@ -1,6 +1,7 @@ package askcli import ( + "fmt" "strings" "testing" ) @@ -27,6 +28,49 @@ func TestFormatTaskList(t *testing.T) { } } +func TestFormatTaskList_AlignsHeaderAndSeparator(t *testing.T) { + tasks := []TaskExport{ + { + UUID: "uuid-short", + Description: "Short task", + Status: "pending", + Priority: "H", + Tags: []string{"cli"}, + Urgency: 1.0, + }, + { + UUID: "uuid-with-a-longer-value", + Description: strings.Repeat("x", 60), + Status: "completed", + Priority: "M", + Tags: []string{"agent", "cli"}, + Urgency: 12.3, + }, + } + + output := FormatTaskList(tasks) + lines := strings.Split(strings.TrimSuffix(output, "\n"), "\n") + if len(lines) != 4 { + t.Fatalf("FormatTaskList produced %d lines, want 4: %q", len(lines), output) + } + + widths := taskListWidthsFor(tasks) + wantHeader := fmt.Sprintf("%-*s | %-*s | %-*s | %-*s | %-*s | %-*s", + widths.Urgency, "Urgency", + widths.Priority, "Priority", + widths.UUID, "UUID", + widths.Status, "Status", + widths.Tags, "Tags", + widths.Description, "Description", + ) + if lines[0] != wantHeader { + t.Fatalf("header = %q, want %q", lines[0], wantHeader) + } + if len(lines[1]) != len(wantHeader) { + t.Fatalf("separator length = %d, want %d", len(lines[1]), len(wantHeader)) + } +} + func TestFormatTaskInfo(t *testing.T) { task := TaskExport{ UUID: "test-uuid", |
