fix(pr create & stubs): handle exitcode in stubs
This commit is contained in:
parent
188e1388b3
commit
bf7bf99f54
2 changed files with 15 additions and 4 deletions
|
|
@ -43,10 +43,21 @@ func (gc *Command) Output() ([]byte, error) {
|
|||
out, err := run.PrepareCmd(gc.Cmd).Output()
|
||||
if err != nil {
|
||||
ge := GitError{err: err}
|
||||
|
||||
// In real implementation, this should be an exec.ExitError, as below,
|
||||
// but the tests use a different type because exec.ExitError are difficult
|
||||
// to create. We want to get the exit code and stderr, but stderr
|
||||
// is not a method and so tests can't access it.
|
||||
// THIS MEANS THAT TESTS WILL NOT CORRECTLY HAVE STDERR SET,
|
||||
// but at least tests can get the exit code.
|
||||
var exitErrorWithExitCode errWithExitCode
|
||||
if errors.As(err, &exitErrorWithExitCode) {
|
||||
ge.ExitCode = exitErrorWithExitCode.ExitCode()
|
||||
}
|
||||
|
||||
var exitError *exec.ExitError
|
||||
if errors.As(err, &exitError) {
|
||||
ge.Stderr = string(exitError.Stderr)
|
||||
ge.ExitCode = exitError.ExitCode()
|
||||
}
|
||||
err = &ge
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue