Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
yahavi committed Nov 29, 2023
1 parent 96ea182 commit 07fe7aa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
5 changes: 1 addition & 4 deletions io/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,7 @@ func RunCmdWithOutputParser(config CmdConfig, prompt bool, regExpStruct ...*CmdO
close(errChan)
}()

for channelErr := range errChan {
err = errors.Join(err, channelErr)
}
if err != nil {
for err = range errChan {
return
}

Expand Down
8 changes: 4 additions & 4 deletions io/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,24 @@ var matchAllRegexp = regexp.MustCompile(".*")
var errParsing = errors.New("parsing error")

func TestRunCmdWithOutputParser(t *testing.T) {
config := NewCommand("git", "", []string{"status"})
config := NewCommand("go", "", []string{"version"})
stdout, stderr, exitOk, err := RunCmdWithOutputParser(config, false, &CmdOutputPattern{
RegExp: matchAllRegexp,
ExecFunc: func(pattern *CmdOutputPattern) (string, error) { return pattern.Line, nil },
})
assert.NoError(t, err)
assert.True(t, exitOk)
assert.Contains(t, stdout, "On branch")
assert.Contains(t, stdout, "go version")
assert.Empty(t, stderr)
}

func TestRunCmdWithOutputParserError(t *testing.T) {
config := NewCommand("git", "", []string{"status"})
config := NewCommand("go", "", []string{"version"})
_, _, exitOk, err := RunCmdWithOutputParser(config, false, &CmdOutputPattern{
RegExp: matchAllRegexp,
ExecFunc: func(pattern *CmdOutputPattern) (string, error) { return pattern.Line, errParsing },
})
assert.ErrorContains(t, err, "parsing error\nparsing error")
assert.ErrorContains(t, err, "parsing error")
assert.False(t, exitOk)
}

Expand Down

0 comments on commit 07fe7aa

Please sign in to comment.