Skip to content

Commit 63a34ad

Browse files
committed
fix: the error output is incorrect
1 parent 85f55ba commit 63a34ad

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

command.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ func (e DefaultExecer) RunCommandAndReturn(name, dir string, args ...string) (re
102102
if err = e.RunCommandWithBuffer(name, dir, stdout, stderr, args...); err == nil {
103103
result = stdout.String()
104104
} else {
105-
result = stderr.String()
105+
result = stdout.String()
106+
result += stderr.String()
106107
}
107108
return
108109
}

fake-command.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ func (f FakeExecer) RunCommandAndReturn(name, dir string, args ...string) (resul
4040
if err = f.ExpectError; err == nil {
4141
result = f.ExpectOutput
4242
} else {
43-
result = f.ExpectErrOutput
43+
result = f.ExpectOutput
44+
result += f.ExpectErrOutput
4445
}
4546
return
4647
}

fake-command_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,10 @@ func TestLookPath(t *testing.T) {
4242

4343
fakeWithErr := FakeExecer{
4444
ExpectError: errors.New("fake"),
45+
ExpectOutput: "output",
4546
ExpectErrOutput: "error",
4647
}
4748
result, err = fakeWithErr.RunCommandAndReturn("", "")
48-
assert.Equal(t, "error", result)
49+
assert.Equal(t, "outputerror", result)
4950
assert.NotNil(t, err)
5051
}

0 commit comments

Comments
 (0)