Skip to content

Commit

Permalink
fix: make pipeline test more robust by ignoring whitespace differences
Browse files Browse the repository at this point in the history
  • Loading branch information
kuhahalong committed Dec 9, 2024
1 parent 4a0937d commit aca020f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/executor/pipeline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package executor
import (
"bytes"
"context"
"strings"
"testing"

"github.com/iamlongalong/runshell/pkg/types"
Expand Down Expand Up @@ -32,7 +33,7 @@ func TestPipelineExecutor(t *testing.T) {
name: "multiple pipes",
cmdStr: "echo hello world | grep hello | wc -l",
wantErr: false,
want: " 1\n",
want: "1\n",
},
{
name: "empty pipeline",
Expand Down Expand Up @@ -75,7 +76,7 @@ func TestPipelineExecutor(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, 0, result.ExitCode)
if tt.want != "" {
assert.Equal(t, tt.want, output.String())
assert.Equal(t, strings.TrimSpace(tt.want), strings.TrimSpace(output.String()))
}
})
}
Expand Down

0 comments on commit aca020f

Please sign in to comment.