From 56c2ffb8f807a8756bb7eeb6f8645cf9e0c96594 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sat, 19 Sep 2026 09:06:39 +0200 Subject: [PATCH] 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) --- pkg/gui/presentation/commits_test.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/gui/presentation/commits_test.go b/pkg/gui/presentation/commits_test.go index 12e0fc1d6..eb5365f03 100644 --- a/pkg/gui/presentation/commits_test.go +++ b/pkg/gui/presentation/commits_test.go @@ -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) {