fixup! refactor(container): restart handling
This commit is contained in:
parent
a0a2e55a67
commit
aba53e7cd3
@ -37,7 +37,6 @@ type DockerClient interface {
|
|||||||
io.Closer
|
io.Closer
|
||||||
|
|
||||||
ContainerCreate(context.Context, *container.Config, *container.HostConfig, *network.NetworkingConfig, *ocispec.Platform, string) (container.CreateResponse, error)
|
ContainerCreate(context.Context, *container.Config, *container.HostConfig, *network.NetworkingConfig, *ocispec.Platform, string) (container.CreateResponse, error)
|
||||||
ContainerInspect(context.Context, string) (container.InspectResponse, error)
|
|
||||||
ContainerList(context.Context, container.ListOptions) ([]container.Summary, error)
|
ContainerList(context.Context, container.ListOptions) ([]container.Summary, error)
|
||||||
ContainerRemove(context.Context, string, container.RemoveOptions) error
|
ContainerRemove(context.Context, string, container.RemoveOptions) error
|
||||||
ContainerStart(context.Context, string, container.StartOptions) error
|
ContainerStart(context.Context, string, container.StartOptions) error
|
||||||
|
@ -69,10 +69,6 @@ func TestClientRunContainer(t *testing.T) {
|
|||||||
EXPECT().
|
EXPECT().
|
||||||
ContainerWait(mock.Anything, "123", dockercontainer.WaitConditionNextExit).
|
ContainerWait(mock.Anything, "123", dockercontainer.WaitConditionNextExit).
|
||||||
Return(containerWaitC, containerErrC)
|
Return(containerWaitC, containerErrC)
|
||||||
dockerClient.
|
|
||||||
EXPECT().
|
|
||||||
ContainerInspect(mock.Anything, "123").
|
|
||||||
Return(dockercontainer.InspectResponse{ContainerJSONBase: &dockercontainer.ContainerJSONBase{State: &dockercontainer.State{Status: "exited"}}}, nil)
|
|
||||||
dockerClient.
|
dockerClient.
|
||||||
EXPECT().
|
EXPECT().
|
||||||
Events(mock.Anything, events.ListOptions{Filters: filters.NewArgs(filters.Arg("container", "123"), filters.Arg("type", "container"))}).
|
Events(mock.Anything, events.ListOptions{Filters: filters.NewArgs(filters.Arg("container", "123"), filters.Arg("type", "container"))}).
|
||||||
@ -98,6 +94,9 @@ func TestClientRunContainer(t *testing.T) {
|
|||||||
Mode: 0755,
|
Mode: 0755,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
ShouldRestart: func(int64, int, time.Duration) (bool, error) {
|
||||||
|
return false, nil
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
done := make(chan struct{})
|
done := make(chan struct{})
|
||||||
@ -122,7 +121,7 @@ func TestClientRunContainer(t *testing.T) {
|
|||||||
assert.Equal(t, "unhealthy", state.HealthState)
|
assert.Equal(t, "unhealthy", state.HealthState)
|
||||||
require.NotNil(t, state.ExitCode)
|
require.NotNil(t, state.ExitCode)
|
||||||
assert.Equal(t, 1, *state.ExitCode)
|
assert.Equal(t, 1, *state.ExitCode)
|
||||||
assert.Equal(t, 1, state.RestartCount)
|
assert.Equal(t, 0, state.RestartCount)
|
||||||
|
|
||||||
<-done
|
<-done
|
||||||
}
|
}
|
||||||
|
@ -138,63 +138,6 @@ func (_c *DockerClient_ContainerCreate_Call) RunAndReturn(run func(context.Conte
|
|||||||
return _c
|
return _c
|
||||||
}
|
}
|
||||||
|
|
||||||
// ContainerInspect provides a mock function with given fields: _a0, _a1
|
|
||||||
func (_m *DockerClient) ContainerInspect(_a0 context.Context, _a1 string) (typescontainer.InspectResponse, error) {
|
|
||||||
ret := _m.Called(_a0, _a1)
|
|
||||||
|
|
||||||
if len(ret) == 0 {
|
|
||||||
panic("no return value specified for ContainerInspect")
|
|
||||||
}
|
|
||||||
|
|
||||||
var r0 typescontainer.InspectResponse
|
|
||||||
var r1 error
|
|
||||||
if rf, ok := ret.Get(0).(func(context.Context, string) (typescontainer.InspectResponse, error)); ok {
|
|
||||||
return rf(_a0, _a1)
|
|
||||||
}
|
|
||||||
if rf, ok := ret.Get(0).(func(context.Context, string) typescontainer.InspectResponse); ok {
|
|
||||||
r0 = rf(_a0, _a1)
|
|
||||||
} else {
|
|
||||||
r0 = ret.Get(0).(typescontainer.InspectResponse)
|
|
||||||
}
|
|
||||||
|
|
||||||
if rf, ok := ret.Get(1).(func(context.Context, string) error); ok {
|
|
||||||
r1 = rf(_a0, _a1)
|
|
||||||
} else {
|
|
||||||
r1 = ret.Error(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
return r0, r1
|
|
||||||
}
|
|
||||||
|
|
||||||
// DockerClient_ContainerInspect_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ContainerInspect'
|
|
||||||
type DockerClient_ContainerInspect_Call struct {
|
|
||||||
*mock.Call
|
|
||||||
}
|
|
||||||
|
|
||||||
// ContainerInspect is a helper method to define mock.On call
|
|
||||||
// - _a0 context.Context
|
|
||||||
// - _a1 string
|
|
||||||
func (_e *DockerClient_Expecter) ContainerInspect(_a0 interface{}, _a1 interface{}) *DockerClient_ContainerInspect_Call {
|
|
||||||
return &DockerClient_ContainerInspect_Call{Call: _e.mock.On("ContainerInspect", _a0, _a1)}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (_c *DockerClient_ContainerInspect_Call) Run(run func(_a0 context.Context, _a1 string)) *DockerClient_ContainerInspect_Call {
|
|
||||||
_c.Call.Run(func(args mock.Arguments) {
|
|
||||||
run(args[0].(context.Context), args[1].(string))
|
|
||||||
})
|
|
||||||
return _c
|
|
||||||
}
|
|
||||||
|
|
||||||
func (_c *DockerClient_ContainerInspect_Call) Return(_a0 typescontainer.InspectResponse, _a1 error) *DockerClient_ContainerInspect_Call {
|
|
||||||
_c.Call.Return(_a0, _a1)
|
|
||||||
return _c
|
|
||||||
}
|
|
||||||
|
|
||||||
func (_c *DockerClient_ContainerInspect_Call) RunAndReturn(run func(context.Context, string) (typescontainer.InspectResponse, error)) *DockerClient_ContainerInspect_Call {
|
|
||||||
_c.Call.Return(run)
|
|
||||||
return _c
|
|
||||||
}
|
|
||||||
|
|
||||||
// ContainerList provides a mock function with given fields: _a0, _a1
|
// ContainerList provides a mock function with given fields: _a0, _a1
|
||||||
func (_m *DockerClient) ContainerList(_a0 context.Context, _a1 typescontainer.ListOptions) ([]typescontainer.Summary, error) {
|
func (_m *DockerClient) ContainerList(_a0 context.Context, _a1 typescontainer.ListOptions) ([]typescontainer.Summary, error) {
|
||||||
ret := _m.Called(_a0, _a1)
|
ret := _m.Called(_a0, _a1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user