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 /cmd/krino/matching_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 'cmd/krino/matching_test.go')
| -rw-r--r-- | cmd/krino/matching_test.go | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/cmd/krino/matching_test.go b/cmd/krino/matching_test.go index 25a2993..6986e99 100644 --- a/cmd/krino/matching_test.go +++ b/cmd/krino/matching_test.go @@ -64,9 +64,9 @@ func TestDryRun(t *testing.T) { } for _, want := range []string{ "krino: dl ~/dl\n8 scanned · 4 to act on · 2 warnings · ", - "\n 1 inv1.txt move → Work/Acme/ acme type txt, content \"acme ltd\"\n", - "\n 2 notes.txt move → Other/ rest not matched, type txt\n", - "\n 4 report (1).pdf move → Dupes/ dups duplicate of report.pdf\n", + "\n 1 inv1.txt\n move → Work/Acme/\n rule acme\n because type txt, content \"acme ltd\"\n", + "\n 2 notes.txt\n move → Other/\n rule rest\n because not matched, type txt\n", + "\n 4 report (1).pdf\n move → Dupes/\n rule dups\n because duplicate of report.pdf\n", "\nwarnings\n brochure.doc acme: content unreadable: needs antiword or catdoc, not installed\n", "\nnot acted on: 1 ignored · 1 busy · 2 unmatched (-v lists them)\n", } { @@ -451,7 +451,10 @@ func TestNoColourEscapeToNonTerminal(t *testing.T) { } } -func TestLongNameNotPaddedLayoutIntact(t *testing.T) { +// TestLongNameGetsItsOwnLine: a long file name sits on its own numbered +// line, and the block below it is laid out exactly as a short name's is. +// Output to a non-terminal is never wrapped. +func TestLongNameGetsItsOwnLine(t *testing.T) { h := home(t) dl := filepath.Join(h, "dl") long := strings.Repeat("a", 42) + ".txt" // 46 runes: past the 40-column cap @@ -488,10 +491,11 @@ func TestLongNameNotPaddedLayoutIntact(t *testing.T) { if code != 0 { t.Fatalf("exit %d: %s", code, errOut) } - if want := "\n 1 " + long + " move → Other/ r type txt\n"; !strings.Contains(out, want) { - t.Errorf("long name should be unpadded (exactly two trailing spaces before the actions column):\n%s\nwant substring:\n%s", out, want) + body := " move → Other/\n rule r\n because type txt\n" + if want := "\n 1 " + long + "\n" + body; !strings.Contains(out, want) { + t.Errorf("long name block:\n%s\nwant substring:\n%s", out, want) } - if want := "\n 2 " + short + strings.Repeat(" ", 40-len(short)) + " move → Other/ r type txt\n"; !strings.Contains(out, want) { - t.Errorf("short name should still be padded to the 40-column cap:\n%s\nwant substring:\n%s", out, want) + if want := "\n 2 " + short + "\n" + body; !strings.Contains(out, want) { + t.Errorf("short name block:\n%s\nwant substring:\n%s", out, want) } } |
