Treat rc
first called as exit code
Because default OsExiter is os.Exit.
This commit is contained in:
parent
70a2c94089
commit
71ced406af
@ -12,9 +12,11 @@ func TestHandleExitCoder_nil(t *testing.T) {
|
|||||||
called := false
|
called := false
|
||||||
|
|
||||||
OsExiter = func(rc int) {
|
OsExiter = func(rc int) {
|
||||||
|
if !called {
|
||||||
exitCode = rc
|
exitCode = rc
|
||||||
called = true
|
called = true
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
defer func() { OsExiter = fakeOsExiter }()
|
defer func() { OsExiter = fakeOsExiter }()
|
||||||
|
|
||||||
@ -29,9 +31,11 @@ func TestHandleExitCoder_ExitCoder(t *testing.T) {
|
|||||||
called := false
|
called := false
|
||||||
|
|
||||||
OsExiter = func(rc int) {
|
OsExiter = func(rc int) {
|
||||||
|
if !called {
|
||||||
exitCode = rc
|
exitCode = rc
|
||||||
called = true
|
called = true
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
defer func() { OsExiter = fakeOsExiter }()
|
defer func() { OsExiter = fakeOsExiter }()
|
||||||
|
|
||||||
@ -46,9 +50,11 @@ func TestHandleExitCoder_MultiErrorWithExitCoder(t *testing.T) {
|
|||||||
called := false
|
called := false
|
||||||
|
|
||||||
OsExiter = func(rc int) {
|
OsExiter = func(rc int) {
|
||||||
|
if !called {
|
||||||
exitCode = rc
|
exitCode = rc
|
||||||
called = true
|
called = true
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
defer func() { OsExiter = fakeOsExiter }()
|
defer func() { OsExiter = fakeOsExiter }()
|
||||||
|
|
||||||
@ -65,9 +71,11 @@ func TestHandleExitCoder_ErrorWithMessage(t *testing.T) {
|
|||||||
called := false
|
called := false
|
||||||
|
|
||||||
OsExiter = func(rc int) {
|
OsExiter = func(rc int) {
|
||||||
|
if !called {
|
||||||
exitCode = rc
|
exitCode = rc
|
||||||
called = true
|
called = true
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ErrWriter = &bytes.Buffer{}
|
ErrWriter = &bytes.Buffer{}
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
@ -88,9 +96,11 @@ func TestHandleExitCoder_ErrorWithoutMessage(t *testing.T) {
|
|||||||
called := false
|
called := false
|
||||||
|
|
||||||
OsExiter = func(rc int) {
|
OsExiter = func(rc int) {
|
||||||
|
if !called {
|
||||||
exitCode = rc
|
exitCode = rc
|
||||||
called = true
|
called = true
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ErrWriter = &bytes.Buffer{}
|
ErrWriter = &bytes.Buffer{}
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
@ -123,8 +133,10 @@ func TestHandleExitCoder_ErrorWithFormat(t *testing.T) {
|
|||||||
called := false
|
called := false
|
||||||
|
|
||||||
OsExiter = func(rc int) {
|
OsExiter = func(rc int) {
|
||||||
|
if !called {
|
||||||
called = true
|
called = true
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ErrWriter = &bytes.Buffer{}
|
ErrWriter = &bytes.Buffer{}
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
@ -143,8 +155,10 @@ func TestHandleExitCoder_MultiErrorWithFormat(t *testing.T) {
|
|||||||
called := false
|
called := false
|
||||||
|
|
||||||
OsExiter = func(rc int) {
|
OsExiter = func(rc int) {
|
||||||
|
if !called {
|
||||||
called = true
|
called = true
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ErrWriter = &bytes.Buffer{}
|
ErrWriter = &bytes.Buffer{}
|
||||||
|
|
||||||
defer func() { OsExiter = fakeOsExiter }()
|
defer func() { OsExiter = fakeOsExiter }()
|
||||||
|
Loading…
Reference in New Issue
Block a user