Added a test for exit code 1 with docker exec
This commit is contained in:
parent
c8c08586f0
commit
709b518d03
|
@ -434,6 +434,25 @@ func (d *fakeDockerClientWithExecNonZeroExitCode) InspectExec(id string) (*docke
|
|||
}, nil
|
||||
}
|
||||
|
||||
// A fake docker client to test exit code which result into Warning
|
||||
type fakeDockerClientWithExecExitCodeOne struct {
|
||||
}
|
||||
|
||||
func (d *fakeDockerClientWithExecExitCodeOne) CreateExec(opts docker.CreateExecOptions) (*docker.Exec, error) {
|
||||
return &docker.Exec{ID: "123"}, nil
|
||||
}
|
||||
|
||||
func (d *fakeDockerClientWithExecExitCodeOne) StartExec(id string, opts docker.StartExecOptions) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *fakeDockerClientWithExecExitCodeOne) InspectExec(id string) (*docker.ExecInspect, error) {
|
||||
return &docker.ExecInspect{
|
||||
ID: "123",
|
||||
ExitCode: 1,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// A fake docker client to simulate create exec failing
|
||||
type fakeDockerClientWithCreateExecFailure struct {
|
||||
}
|
||||
|
@ -525,6 +544,10 @@ func TestDockerCheckWhenExitCodeIsNonZero(t *testing.T) {
|
|||
expectDockerCheckStatus(t, &fakeDockerClientWithExecNonZeroExitCode{}, "critical")
|
||||
}
|
||||
|
||||
func TestDockerCheckWhenExitCodeIsone(t *testing.T) {
|
||||
expectDockerCheckStatus(t, &fakeDockerClientWithExecExitCodeOne{}, "warning")
|
||||
}
|
||||
|
||||
func TestDockerCheckWhenExecStartFails(t *testing.T) {
|
||||
expectDockerCheckStatus(t, &fakeDockerClientWithStartExecFailure{}, "critical")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue