diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-09-14 13:26:51 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-09-14 13:26:51 +0200 |
| commit | 07c24054cab965800983ef40f53a05c2db131ede (patch) | |
| tree | 741db561d614b35f8f94fee04fb5ce663a629a0b /internal/tui/tui_test.go | |
| parent | 70dccf8d573028aaed64185acb8e134e5339afa3 (diff) | |
| download | krino-07c24054cab965800983ef40f53a05c2db131ede.tar.gz krino-07c24054cab965800983ef40f53a05c2db131ede.zip | |
krino: 0.0.3 — the plan as one block per file, wrapped, and -Pv0.0.3
Each file shows its steps, then the rule and the reason it matched, one
field per line; on a terminal every line wraps to its width with
continuation lines under their own column, and piped output is never
wrapped. Choosing per file shows the same block. -P / --no-pager prints
the plan without the pager. A duplicate's original is shown with ~.
Diffstat (limited to 'internal/tui/tui_test.go')
| -rw-r--r-- | internal/tui/tui_test.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/internal/tui/tui_test.go b/internal/tui/tui_test.go index a3640ac..614f239 100644 --- a/internal/tui/tui_test.go +++ b/internal/tui/tui_test.go @@ -51,6 +51,28 @@ func TestHeight(t *testing.T) { } } +// TestWidth: the terminal's column count, and 0 wherever there is no +// terminal to wrap to, so a caller treats 0 as "never wrap". +func TestWidth(t *testing.T) { + var buf bytes.Buffer + if w := Width(&buf); w != 0 { + t.Errorf("Width on a non-terminal writer = %d, want 0", w) + } + + oldT, oldS := isTerminal, termSize + t.Cleanup(func() { isTerminal, termSize = oldT, oldS }) + isTerminal = func(fd int) bool { return true } + termSize = func(fd int) (int, int, error) { return 132, 24, nil } + if w := Width(os.Stdout); w != 132 { + t.Errorf("Width = %d, want 132", w) + } + + termSize = func(fd int) (int, int, error) { return 0, 0, os.ErrInvalid } + if w := Width(os.Stdout); w != 0 { + t.Errorf("Width when the size cannot be read = %d, want 0", w) + } +} + func TestPageUsesPagerOnlyWhenTaller(t *testing.T) { dir := t.TempDir() marker := filepath.Join(dir, "paged") |
