Don't strip leading spaces from a scenario's expected output

formatExpected runs the expected output through strings.TrimSpace to get
rid of the newlines that the raw string literal starts and ends with, but
that also eats the indentation of the first line. A scenario whose first
line starts with an empty column can't express what it expects, and a
later commit adds two of those. Trim the newlines only.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Stefan Haller
2026-09-19 10:16:04 +02:00
co-authored by Claude Opus 5
parent 43e63bcc24
commit 56c2ffb8f8
+6 -1
View File
@@ -17,8 +17,13 @@ import (
"github.com/xo/terminfo"
)
// Scenarios write their expected output as a raw string literal, indented with
// tabs so that it lines up with the surrounding code. Strip that indentation,
// along with the newlines after the opening backtick and before the closing
// one. Spaces are left alone, so that a scenario can expect a line that starts
// with an empty column.
func formatExpected(expected string) string {
return strings.TrimSpace(strings.ReplaceAll(expected, "\t", ""))
return strings.Trim(strings.ReplaceAll(expected, "\t", ""), "\n")
}
func TestGetCommitListDisplayStrings(t *testing.T) {