summaryrefslogtreecommitdiff
path: root/cmd/krino/matching_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/krino/matching_test.go')
-rw-r--r--cmd/krino/matching_test.go20
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)
}
}