From f21f0c1358df4737314f389bad225ce8225fe9ed Mon Sep 17 00:00:00 2001 From: Cloud-Architect-Emma Date: Sat, 30 May 2026 17:57:34 +0100 Subject: [PATCH] test(action): simplify trailing newline assertion Co-authored-by: Cloud-Architect-Emma Signed-off-by: Cloud-Architect-Emma --- pkg/action/install_test.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/pkg/action/install_test.go b/pkg/action/install_test.go index da68f4521..d8c523262 100644 --- a/pkg/action/install_test.go +++ b/pkg/action/install_test.go @@ -1299,7 +1299,6 @@ func TestInstallRelease_WaitOptionsPassedDownstream(t *testing.T) { } func TestWriteToFileNoTrailingNewline(t *testing.T) { - is := assert.New(t) instAction := installAction(t) vals := map[string]any{} @@ -1311,7 +1310,7 @@ func TestWriteToFileNoTrailingNewline(t *testing.T) { t.Fatalf("Failed install: %s", err) } - // Each output file should end with exactly one newline, not two. + // Each output file should end with exactly one newline (no double newline). for _, name := range []string{ "hello/templates/hello", "hello/templates/goodbye", @@ -1321,10 +1320,12 @@ func TestWriteToFileNoTrailingNewline(t *testing.T) { if err != nil { t.Fatalf("Failed to read %s: %s", path, err) } - is.True(len(data) > 0, "file should not be empty: %s", name) - is.Equal(byte('\n'), data[len(data)-1], "file should end with exactly one newline: %s", name) - if len(data) >= 2 { - is.NotEqual(byte('\n'), data[len(data)-2], "file should not end with two newlines: %s", name) + content := string(data) + if strings.HasSuffix(content, "\n\n") { + t.Errorf("file %s ends with double newline, expected single newline", name) + } + if !strings.HasSuffix(content, "\n") { + t.Errorf("file %s does not end with a newline", name) } } -} +} \ No newline at end of file