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 0328729
Showing 1 changed file with 4 additions and 4 deletions.
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 0328729

Please sign in to comment.