aboutsummaryrefslogtreecommitdiff
path: root/cmd/krino/review_test.go
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-09-15 00:29:09 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-09-15 00:29:09 +0200
commit17e933a16ff7de1b06d62504e78c40e615c8b553 (patch)
tree0ceb58ff18f9ee6f35fbcb6255c8a830e6124b84 /cmd/krino/review_test.go
parent59015f1f91d640502fdfc34019cf0154b5206bb8 (diff)
downloadkrino-17e933a16ff7de1b06d62504e78c40e615c8b553.tar.gz
krino-17e933a16ff7de1b06d62504e78c40e615c8b553.zip
review and undo headings wrap past the label column; format characters take a column
Diffstat (limited to 'cmd/krino/review_test.go')
-rw-r--r--cmd/krino/review_test.go39
1 files changed, 39 insertions, 0 deletions
diff --git a/cmd/krino/review_test.go b/cmd/krino/review_test.go
index b138451..fc175cb 100644
--- a/cmd/krino/review_test.go
+++ b/cmd/krino/review_test.go
@@ -11,6 +11,7 @@ import (
"testing"
"unicode/utf8"
+ "krino/internal/engine"
"krino/internal/plan"
"krino/internal/scan"
)
@@ -326,3 +327,41 @@ func TestStopAfterApply(t *testing.T) {
}
}
}
+
+// TestReviewHeadingsCannotFakeAStepLine: a long name in the per-file
+// heading of review and of undo wraps with its continuation past the column
+// step labels use, so the name cannot pass for a step (plan 11 review L4).
+func TestReviewHeadingsCannotFakeAStepLine(t *testing.T) {
+ old := widthPolicy
+ t.Cleanup(func() { widthPolicy = old })
+ widthPolicy = func(io.Writer) int { return 60 }
+ name := strings.Repeat("x", 50) + " DELETE permanently"
+
+ out := new(strings.Builder)
+ cs := []plan.Chain{{File: scan.File{Rel: name}, Steps: []plan.Step{{Kind: plan.Move, Rule: "r", Dst: "/w/Out/a.pdf"}}}}
+ if _, _, _, err := reviewChains(strings.NewReader("cy"), out, cs, "/w", palette{}); err != nil {
+ t.Fatal(err)
+ }
+ for _, l := range strings.Split(out.String(), "\n") {
+ if strings.HasPrefix(strings.TrimLeft(l, " "), "DELETE") {
+ t.Errorf("review: a line reads as a step: %q\n%s", l, out)
+ }
+ if n := cols(l); n > 60 {
+ t.Errorf("review: a line of %d columns, over 60, which the terminal wraps: %q", n, l)
+ }
+ }
+
+ out.Reset()
+ files := []engine.UndoFile{{Dir: "dl", File: name, Steps: []engine.UndoStep{{Action: "undo-move", Src: "/t/a", Dst: "/s/a"}}}}
+ if _, _, err := reviewUndoFiles(strings.NewReader("cy"), out, files, palette{}); err != nil {
+ t.Fatal(err)
+ }
+ for _, l := range strings.Split(out.String(), "\n") {
+ if strings.HasPrefix(strings.TrimLeft(l, " "), "DELETE") {
+ t.Errorf("undo: a line reads as a step: %q\n%s", l, out)
+ }
+ if n := cols(l); n > 60 {
+ t.Errorf("undo: a line of %d columns, over 60, which the terminal wraps: %q", n, l)
+ }
+ }
+}