Skip to content

Commit c976bb3

Browse files
committed
Add exiterror test
1 parent 7b814e3 commit c976bb3

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

localexec_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,19 @@ func testExecer(ctx context.Context, t *testing.T, execer Execer) {
5454
err = process.Wait()
5555
assert.Success(t, "wait for process to complete", err)
5656
}
57+
58+
func TestExitCode(t *testing.T) {
59+
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
60+
defer cancel()
61+
62+
process, err := LocalExecer{}.Start(ctx, Command{
63+
Command: "/bin/sh",
64+
Args: []string{"-c", `"fakecommand"`},
65+
})
66+
assert.Success(t, "start local cmd", err)
67+
68+
err = process.Wait()
69+
exitErr, ok := err.(*ExitError)
70+
assert.True(t, "error is *ExitError", ok)
71+
assert.Equal(t, "exit error", exitErr.Code, 127)
72+
}

0 commit comments

Comments
 (0)