|
|
|
@ -12,9 +12,11 @@ func TestHandleExitCoder_nil(t *testing.T) {
|
|
|
|
|
called := false
|
|
|
|
|
|
|
|
|
|
OsExiter = func(rc int) {
|
|
|
|
|
if !called {
|
|
|
|
|
exitCode = rc
|
|
|
|
|
called = true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
defer func() { OsExiter = fakeOsExiter }()
|
|
|
|
|
|
|
|
|
@ -29,9 +31,11 @@ func TestHandleExitCoder_ExitCoder(t *testing.T) {
|
|
|
|
|
called := false
|
|
|
|
|
|
|
|
|
|
OsExiter = func(rc int) {
|
|
|
|
|
if !called {
|
|
|
|
|
exitCode = rc
|
|
|
|
|
called = true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
defer func() { OsExiter = fakeOsExiter }()
|
|
|
|
|
|
|
|
|
@ -46,17 +50,20 @@ func TestHandleExitCoder_MultiErrorWithExitCoder(t *testing.T) {
|
|
|
|
|
called := false
|
|
|
|
|
|
|
|
|
|
OsExiter = func(rc int) {
|
|
|
|
|
if !called {
|
|
|
|
|
exitCode = rc
|
|
|
|
|
called = true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
defer func() { OsExiter = fakeOsExiter }()
|
|
|
|
|
|
|
|
|
|
exitErr := NewExitError("galactic perimeter breach", 9)
|
|
|
|
|
err := NewMultiError(errors.New("wowsa"), errors.New("egad"), exitErr)
|
|
|
|
|
exitErr2 := NewExitError("last ExitCoder", 11)
|
|
|
|
|
err := NewMultiError(errors.New("wowsa"), errors.New("egad"), exitErr, exitErr2)
|
|
|
|
|
HandleExitCoder(err)
|
|
|
|
|
|
|
|
|
|
expect(t, exitCode, 9)
|
|
|
|
|
expect(t, exitCode, 11)
|
|
|
|
|
expect(t, called, true)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -65,9 +72,11 @@ func TestHandleExitCoder_ErrorWithMessage(t *testing.T) {
|
|
|
|
|
called := false
|
|
|
|
|
|
|
|
|
|
OsExiter = func(rc int) {
|
|
|
|
|
if !called {
|
|
|
|
|
exitCode = rc
|
|
|
|
|
called = true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ErrWriter = &bytes.Buffer{}
|
|
|
|
|
|
|
|
|
|
defer func() {
|
|
|
|
@ -88,9 +97,11 @@ func TestHandleExitCoder_ErrorWithoutMessage(t *testing.T) {
|
|
|
|
|
called := false
|
|
|
|
|
|
|
|
|
|
OsExiter = func(rc int) {
|
|
|
|
|
if !called {
|
|
|
|
|
exitCode = rc
|
|
|
|
|
called = true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ErrWriter = &bytes.Buffer{}
|
|
|
|
|
|
|
|
|
|
defer func() {
|
|
|
|
@ -123,8 +134,10 @@ func TestHandleExitCoder_ErrorWithFormat(t *testing.T) {
|
|
|
|
|
called := false
|
|
|
|
|
|
|
|
|
|
OsExiter = func(rc int) {
|
|
|
|
|
if !called {
|
|
|
|
|
called = true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ErrWriter = &bytes.Buffer{}
|
|
|
|
|
|
|
|
|
|
defer func() {
|
|
|
|
@ -143,8 +156,10 @@ func TestHandleExitCoder_MultiErrorWithFormat(t *testing.T) {
|
|
|
|
|
called := false
|
|
|
|
|
|
|
|
|
|
OsExiter = func(rc int) {
|
|
|
|
|
if !called {
|
|
|
|
|
called = true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ErrWriter = &bytes.Buffer{}
|
|
|
|
|
|
|
|
|
|
defer func() { OsExiter = fakeOsExiter }()
|
|
|
|
|