mirror of https://github.com/docker/docs.git
Plumbing context through all calls to engine-api client
Signed-off-by: Nishant Totla <nishanttotla@gmail.com>
This commit is contained in:
parent
611f273c76
commit
1e821e48ed
|
@ -30,56 +30,56 @@ func (client *MockClient) ClientVersion() string {
|
|||
}
|
||||
|
||||
// ContainerAttach attaches a connection to a container in the server
|
||||
func (client *MockClient) ContainerAttach(options types.ContainerAttachOptions) (types.HijackedResponse, error) {
|
||||
args := client.Mock.Called(options)
|
||||
func (client *MockClient) ContainerAttach(ctx context.Context, options types.ContainerAttachOptions) (types.HijackedResponse, error) {
|
||||
args := client.Mock.Called(ctx, options)
|
||||
return args.Get(0).(types.HijackedResponse), args.Error(1)
|
||||
}
|
||||
|
||||
// ContainerCommit applies changes into a container and creates a new tagged image
|
||||
func (client *MockClient) ContainerCommit(options types.ContainerCommitOptions) (types.ContainerCommitResponse, error) {
|
||||
args := client.Mock.Called(options)
|
||||
func (client *MockClient) ContainerCommit(ctx context.Context, options types.ContainerCommitOptions) (types.ContainerCommitResponse, error) {
|
||||
args := client.Mock.Called(ctx, options)
|
||||
return args.Get(0).(types.ContainerCommitResponse), args.Error(1)
|
||||
}
|
||||
|
||||
// ContainerCreate creates a new container based in the given configuration
|
||||
func (client *MockClient) ContainerCreate(config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, containerName string) (types.ContainerCreateResponse, error) {
|
||||
args := client.Mock.Called(config, hostConfig, networkingConfig, containerName)
|
||||
func (client *MockClient) ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, containerName string) (types.ContainerCreateResponse, error) {
|
||||
args := client.Mock.Called(ctx, config, hostConfig, networkingConfig, containerName)
|
||||
return args.Get(0).(types.ContainerCreateResponse), args.Error(1)
|
||||
}
|
||||
|
||||
// ContainerDiff shows differences in a container filesystem since it was started
|
||||
func (client *MockClient) ContainerDiff(containerID string) ([]types.ContainerChange, error) {
|
||||
args := client.Mock.Called(containerID)
|
||||
func (client *MockClient) ContainerDiff(ctx context.Context, containerID string) ([]types.ContainerChange, error) {
|
||||
args := client.Mock.Called(ctx, containerID)
|
||||
return args.Get(0).([]types.ContainerChange), args.Error(1)
|
||||
}
|
||||
|
||||
// ContainerExecAttach attaches a connection to an exec process in the server
|
||||
func (client *MockClient) ContainerExecAttach(execID string, config types.ExecConfig) (types.HijackedResponse, error) {
|
||||
args := client.Mock.Called(execID, config)
|
||||
func (client *MockClient) ContainerExecAttach(ctx context.Context, execID string, config types.ExecConfig) (types.HijackedResponse, error) {
|
||||
args := client.Mock.Called(ctx, execID, config)
|
||||
return args.Get(0).(types.HijackedResponse), args.Error(1)
|
||||
}
|
||||
|
||||
// ContainerExecCreate creates a new exec configuration to run an exec process
|
||||
func (client *MockClient) ContainerExecCreate(config types.ExecConfig) (types.ContainerExecCreateResponse, error) {
|
||||
args := client.Mock.Called(config)
|
||||
func (client *MockClient) ContainerExecCreate(ctx context.Context, config types.ExecConfig) (types.ContainerExecCreateResponse, error) {
|
||||
args := client.Mock.Called(ctx, config)
|
||||
return args.Get(0).(types.ContainerExecCreateResponse), args.Error(1)
|
||||
}
|
||||
|
||||
// ContainerExecInspect returns information about a specific exec process on the docker host
|
||||
func (client *MockClient) ContainerExecInspect(execID string) (types.ContainerExecInspect, error) {
|
||||
args := client.Mock.Called(execID)
|
||||
func (client *MockClient) ContainerExecInspect(ctx context.Context, execID string) (types.ContainerExecInspect, error) {
|
||||
args := client.Mock.Called(ctx, execID)
|
||||
return args.Get(0).(types.ContainerExecInspect), args.Error(1)
|
||||
}
|
||||
|
||||
// ContainerExecResize changes the size of the tty for an exec process running inside a container
|
||||
func (client *MockClient) ContainerExecResize(options types.ResizeOptions) error {
|
||||
args := client.Mock.Called(options)
|
||||
func (client *MockClient) ContainerExecResize(ctx context.Context, options types.ResizeOptions) error {
|
||||
args := client.Mock.Called(ctx, options)
|
||||
return args.Error(0)
|
||||
}
|
||||
|
||||
// ContainerExecStart starts an exec process already create in the docker host
|
||||
func (client *MockClient) ContainerExecStart(execID string, config types.ExecStartCheck) error {
|
||||
args := client.Mock.Called(execID, config)
|
||||
func (client *MockClient) ContainerExecStart(ctx context.Context, execID string, config types.ExecStartCheck) error {
|
||||
args := client.Mock.Called(ctx, execID, config)
|
||||
return args.Error(0)
|
||||
}
|
||||
|
||||
|
@ -90,26 +90,26 @@ func (client *MockClient) ContainerExport(ctx context.Context, containerID strin
|
|||
}
|
||||
|
||||
// ContainerInspect returns the container information
|
||||
func (client *MockClient) ContainerInspect(containerID string) (types.ContainerJSON, error) {
|
||||
args := client.Mock.Called(containerID)
|
||||
func (client *MockClient) ContainerInspect(ctx context.Context, containerID string) (types.ContainerJSON, error) {
|
||||
args := client.Mock.Called(ctx, containerID)
|
||||
return args.Get(0).(types.ContainerJSON), args.Error(1)
|
||||
}
|
||||
|
||||
// ContainerInspectWithRaw returns the container information and its raw representation
|
||||
func (client *MockClient) ContainerInspectWithRaw(containerID string, getSize bool) (types.ContainerJSON, []byte, error) {
|
||||
args := client.Mock.Called(containerID, getSize)
|
||||
func (client *MockClient) ContainerInspectWithRaw(ctx context.Context, containerID string, getSize bool) (types.ContainerJSON, []byte, error) {
|
||||
args := client.Mock.Called(ctx, containerID, getSize)
|
||||
return args.Get(0).(types.ContainerJSON), args.Get(1).([]byte), args.Error(2)
|
||||
}
|
||||
|
||||
// ContainerKill terminates the container process but does not remove the container from the docker host
|
||||
func (client *MockClient) ContainerKill(containerID, signal string) error {
|
||||
args := client.Mock.Called(containerID, signal)
|
||||
func (client *MockClient) ContainerKill(ctx context.Context, containerID, signal string) error {
|
||||
args := client.Mock.Called(ctx, containerID, signal)
|
||||
return args.Error(0)
|
||||
}
|
||||
|
||||
// ContainerList returns the list of containers in the docker host
|
||||
func (client *MockClient) ContainerList(options types.ContainerListOptions) ([]types.Container, error) {
|
||||
args := client.Mock.Called(options)
|
||||
func (client *MockClient) ContainerList(ctx context.Context, options types.ContainerListOptions) ([]types.Container, error) {
|
||||
args := client.Mock.Called(ctx, options)
|
||||
return args.Get(0).([]types.Container), args.Error(1)
|
||||
}
|
||||
|
||||
|
@ -120,38 +120,38 @@ func (client *MockClient) ContainerLogs(ctx context.Context, options types.Conta
|
|||
}
|
||||
|
||||
// ContainerPause pauses the main process of a given container without terminating it
|
||||
func (client *MockClient) ContainerPause(containerID string) error {
|
||||
args := client.Mock.Called(containerID)
|
||||
func (client *MockClient) ContainerPause(ctx context.Context, containerID string) error {
|
||||
args := client.Mock.Called(ctx, containerID)
|
||||
return args.Error(0)
|
||||
}
|
||||
|
||||
// ContainerRemove kills and removes a container from the docker host
|
||||
func (client *MockClient) ContainerRemove(options types.ContainerRemoveOptions) error {
|
||||
args := client.Mock.Called(options)
|
||||
func (client *MockClient) ContainerRemove(ctx context.Context, options types.ContainerRemoveOptions) error {
|
||||
args := client.Mock.Called(ctx, options)
|
||||
return args.Error(0)
|
||||
}
|
||||
|
||||
// ContainerRename changes the name of a given container
|
||||
func (client *MockClient) ContainerRename(containerID, newContainerName string) error {
|
||||
args := client.Mock.Called(containerID, newContainerName)
|
||||
func (client *MockClient) ContainerRename(ctx context.Context, containerID, newContainerName string) error {
|
||||
args := client.Mock.Called(ctx, containerID, newContainerName)
|
||||
return args.Error(0)
|
||||
}
|
||||
|
||||
// ContainerResize changes the size of the tty for a container
|
||||
func (client *MockClient) ContainerResize(options types.ResizeOptions) error {
|
||||
args := client.Mock.Called(options)
|
||||
func (client *MockClient) ContainerResize(ctx context.Context, options types.ResizeOptions) error {
|
||||
args := client.Mock.Called(ctx, options)
|
||||
return args.Error(0)
|
||||
}
|
||||
|
||||
// ContainerRestart stops and starts a container again
|
||||
func (client *MockClient) ContainerRestart(containerID string, timeout int) error {
|
||||
args := client.Mock.Called(containerID, timeout)
|
||||
func (client *MockClient) ContainerRestart(ctx context.Context, containerID string, timeout int) error {
|
||||
args := client.Mock.Called(ctx, containerID, timeout)
|
||||
return args.Error(0)
|
||||
}
|
||||
|
||||
// ContainerStatPath returns Stat information about a path inside the container filesystem
|
||||
func (client *MockClient) ContainerStatPath(containerID, path string) (types.ContainerPathStat, error) {
|
||||
args := client.Mock.Called(containerID, path)
|
||||
func (client *MockClient) ContainerStatPath(ctx context.Context, containerID, path string) (types.ContainerPathStat, error) {
|
||||
args := client.Mock.Called(ctx, containerID, path)
|
||||
return args.Get(0).(types.ContainerPathStat), args.Error(1)
|
||||
}
|
||||
|
||||
|
@ -162,32 +162,32 @@ func (client *MockClient) ContainerStats(ctx context.Context, containerID string
|
|||
}
|
||||
|
||||
// ContainerStart sends a request to the docker daemon to start a container
|
||||
func (client *MockClient) ContainerStart(containerID string) error {
|
||||
args := client.Mock.Called(containerID)
|
||||
func (client *MockClient) ContainerStart(ctx context.Context, containerID string) error {
|
||||
args := client.Mock.Called(ctx, containerID)
|
||||
return args.Error(0)
|
||||
}
|
||||
|
||||
// ContainerStop stops a container without terminating the process
|
||||
func (client *MockClient) ContainerStop(containerID string, timeout int) error {
|
||||
args := client.Mock.Called(containerID, timeout)
|
||||
func (client *MockClient) ContainerStop(ctx context.Context, containerID string, timeout int) error {
|
||||
args := client.Mock.Called(ctx, containerID, timeout)
|
||||
return args.Error(0)
|
||||
}
|
||||
|
||||
// ContainerTop shows process information from within a container
|
||||
func (client *MockClient) ContainerTop(containerID string, arguments []string) (types.ContainerProcessList, error) {
|
||||
args := client.Mock.Called(containerID, arguments)
|
||||
func (client *MockClient) ContainerTop(ctx context.Context, containerID string, arguments []string) (types.ContainerProcessList, error) {
|
||||
args := client.Mock.Called(ctx, containerID, arguments)
|
||||
return args.Get(0).(types.ContainerProcessList), args.Error(1)
|
||||
}
|
||||
|
||||
// ContainerUnpause resumes the process execution within a container
|
||||
func (client *MockClient) ContainerUnpause(containerID string) error {
|
||||
args := client.Mock.Called(containerID)
|
||||
func (client *MockClient) ContainerUnpause(ctx context.Context, containerID string) error {
|
||||
args := client.Mock.Called(ctx, containerID)
|
||||
return args.Error(0)
|
||||
}
|
||||
|
||||
// ContainerUpdate updates resources of a container
|
||||
func (client *MockClient) ContainerUpdate(containerID string, updateConfig container.UpdateConfig) error {
|
||||
args := client.Mock.Called(containerID, updateConfig)
|
||||
func (client *MockClient) ContainerUpdate(ctx context.Context, containerID string, updateConfig container.UpdateConfig) error {
|
||||
args := client.Mock.Called(ctx, containerID, updateConfig)
|
||||
return args.Error(0)
|
||||
}
|
||||
|
||||
|
@ -228,8 +228,8 @@ func (client *MockClient) ImageCreate(ctx context.Context, options types.ImageCr
|
|||
}
|
||||
|
||||
// ImageHistory returns the changes in an image in history format
|
||||
func (client *MockClient) ImageHistory(imageID string) ([]types.ImageHistory, error) {
|
||||
args := client.Mock.Called(imageID)
|
||||
func (client *MockClient) ImageHistory(ctx context.Context, imageID string) ([]types.ImageHistory, error) {
|
||||
args := client.Mock.Called(ctx, imageID)
|
||||
return args.Get(0).([]types.ImageHistory), args.Error(1)
|
||||
}
|
||||
|
||||
|
@ -240,14 +240,14 @@ func (client *MockClient) ImageImport(ctx context.Context, options types.ImageIm
|
|||
}
|
||||
|
||||
// ImageInspectWithRaw returns the image information and it's raw representation
|
||||
func (client *MockClient) ImageInspectWithRaw(imageID string, getSize bool) (types.ImageInspect, []byte, error) {
|
||||
args := client.Mock.Called(imageID, getSize)
|
||||
func (client *MockClient) ImageInspectWithRaw(ctx context.Context, imageID string, getSize bool) (types.ImageInspect, []byte, error) {
|
||||
args := client.Mock.Called(ctx, imageID, getSize)
|
||||
return args.Get(0).(types.ImageInspect), args.Get(1).([]byte), args.Error(2)
|
||||
}
|
||||
|
||||
// ImageList returns a list of images in the docker host
|
||||
func (client *MockClient) ImageList(options types.ImageListOptions) ([]types.Image, error) {
|
||||
args := client.Mock.Called(options)
|
||||
func (client *MockClient) ImageList(ctx context.Context, options types.ImageListOptions) ([]types.Image, error) {
|
||||
args := client.Mock.Called(ctx, options)
|
||||
return args.Get(0).([]types.Image), args.Error(1)
|
||||
}
|
||||
|
||||
|
@ -270,14 +270,14 @@ func (client *MockClient) ImagePush(ctx context.Context, options types.ImagePush
|
|||
}
|
||||
|
||||
// ImageRemove removes an image from the docker host
|
||||
func (client *MockClient) ImageRemove(options types.ImageRemoveOptions) ([]types.ImageDelete, error) {
|
||||
args := client.Mock.Called(options)
|
||||
func (client *MockClient) ImageRemove(ctx context.Context, options types.ImageRemoveOptions) ([]types.ImageDelete, error) {
|
||||
args := client.Mock.Called(ctx, options)
|
||||
return args.Get(0).([]types.ImageDelete), args.Error(1)
|
||||
}
|
||||
|
||||
// ImageSearch makes the docker host to search by a term in a remote registry
|
||||
func (client *MockClient) ImageSearch(options types.ImageSearchOptions, privilegeFunc client.RequestPrivilegeFunc) ([]registry.SearchResult, error) {
|
||||
args := client.Mock.Called(options, privilegeFunc)
|
||||
func (client *MockClient) ImageSearch(ctx context.Context, options types.ImageSearchOptions, privilegeFunc client.RequestPrivilegeFunc) ([]registry.SearchResult, error) {
|
||||
args := client.Mock.Called(ctx, options, privilegeFunc)
|
||||
return args.Get(0).([]registry.SearchResult), args.Error(1)
|
||||
}
|
||||
|
||||
|
@ -288,85 +288,85 @@ func (client *MockClient) ImageSave(ctx context.Context, imageIDs []string) (io.
|
|||
}
|
||||
|
||||
// ImageTag tags an image in the docker host
|
||||
func (client *MockClient) ImageTag(options types.ImageTagOptions) error {
|
||||
args := client.Mock.Called(options)
|
||||
func (client *MockClient) ImageTag(ctx context.Context, options types.ImageTagOptions) error {
|
||||
args := client.Mock.Called(ctx, options)
|
||||
return args.Error(0)
|
||||
}
|
||||
|
||||
// Info returns information about the docker server
|
||||
func (client *MockClient) Info() (types.Info, error) {
|
||||
args := client.Mock.Called()
|
||||
func (client *MockClient) Info(ctx context.Context) (types.Info, error) {
|
||||
args := client.Mock.Called(ctx)
|
||||
return args.Get(0).(types.Info), args.Error(1)
|
||||
}
|
||||
|
||||
// NetworkConnect connects a container to an existent network in the docker host
|
||||
func (client *MockClient) NetworkConnect(networkID, containerID string, config *network.EndpointSettings) error {
|
||||
args := client.Mock.Called(networkID, containerID, config)
|
||||
func (client *MockClient) NetworkConnect(ctx context.Context, networkID, containerID string, config *network.EndpointSettings) error {
|
||||
args := client.Mock.Called(ctx, networkID, containerID, config)
|
||||
return args.Error(0)
|
||||
}
|
||||
|
||||
// NetworkCreate creates a new network in the docker host
|
||||
func (client *MockClient) NetworkCreate(options types.NetworkCreate) (types.NetworkCreateResponse, error) {
|
||||
args := client.Mock.Called(options)
|
||||
func (client *MockClient) NetworkCreate(ctx context.Context, options types.NetworkCreate) (types.NetworkCreateResponse, error) {
|
||||
args := client.Mock.Called(ctx, options)
|
||||
return args.Get(0).(types.NetworkCreateResponse), args.Error(1)
|
||||
}
|
||||
|
||||
// NetworkDisconnect disconnects a container from an existent network in the docker host
|
||||
func (client *MockClient) NetworkDisconnect(networkID, containerID string, force bool) error {
|
||||
args := client.Mock.Called(networkID, containerID, force)
|
||||
func (client *MockClient) NetworkDisconnect(ctx context.Context, networkID, containerID string, force bool) error {
|
||||
args := client.Mock.Called(ctx, networkID, containerID, force)
|
||||
return args.Error(0)
|
||||
}
|
||||
|
||||
// NetworkInspect returns the information for a specific network configured in the docker host
|
||||
func (client *MockClient) NetworkInspect(networkID string) (types.NetworkResource, error) {
|
||||
args := client.Mock.Called(networkID)
|
||||
func (client *MockClient) NetworkInspect(ctx context.Context, networkID string) (types.NetworkResource, error) {
|
||||
args := client.Mock.Called(ctx, networkID)
|
||||
return args.Get(0).(types.NetworkResource), args.Error(1)
|
||||
}
|
||||
|
||||
// NetworkList returns the list of networks configured in the docker host
|
||||
func (client *MockClient) NetworkList(options types.NetworkListOptions) ([]types.NetworkResource, error) {
|
||||
args := client.Mock.Called(options)
|
||||
func (client *MockClient) NetworkList(ctx context.Context, options types.NetworkListOptions) ([]types.NetworkResource, error) {
|
||||
args := client.Mock.Called(ctx, options)
|
||||
return args.Get(0).([]types.NetworkResource), args.Error(1)
|
||||
}
|
||||
|
||||
// NetworkRemove removes an existent network from the docker host
|
||||
func (client *MockClient) NetworkRemove(networkID string) error {
|
||||
args := client.Mock.Called(networkID)
|
||||
func (client *MockClient) NetworkRemove(ctx context.Context, networkID string) error {
|
||||
args := client.Mock.Called(ctx, networkID)
|
||||
return args.Error(0)
|
||||
}
|
||||
|
||||
// RegistryLogin authenticates the docker server with a given docker registry
|
||||
func (client *MockClient) RegistryLogin(auth types.AuthConfig) (types.AuthResponse, error) {
|
||||
args := client.Mock.Called(auth)
|
||||
func (client *MockClient) RegistryLogin(ctx context.Context, auth types.AuthConfig) (types.AuthResponse, error) {
|
||||
args := client.Mock.Called(ctx, auth)
|
||||
return args.Get(0).(types.AuthResponse), args.Error(1)
|
||||
}
|
||||
|
||||
// ServerVersion returns information of the docker client and server host
|
||||
func (client *MockClient) ServerVersion() (types.Version, error) {
|
||||
args := client.Mock.Called()
|
||||
func (client *MockClient) ServerVersion(ctx context.Context) (types.Version, error) {
|
||||
args := client.Mock.Called(ctx)
|
||||
return args.Get(0).(types.Version), args.Error(1)
|
||||
}
|
||||
|
||||
// VolumeCreate creates a volume in the docker host
|
||||
func (client *MockClient) VolumeCreate(options types.VolumeCreateRequest) (types.Volume, error) {
|
||||
args := client.Mock.Called(options)
|
||||
func (client *MockClient) VolumeCreate(ctx context.Context, options types.VolumeCreateRequest) (types.Volume, error) {
|
||||
args := client.Mock.Called(ctx, options)
|
||||
return args.Get(0).(types.Volume), args.Error(1)
|
||||
}
|
||||
|
||||
// VolumeInspect returns the information about a specific volume in the docker host
|
||||
func (client *MockClient) VolumeInspect(volumeID string) (types.Volume, error) {
|
||||
args := client.Mock.Called(volumeID)
|
||||
func (client *MockClient) VolumeInspect(ctx context.Context, volumeID string) (types.Volume, error) {
|
||||
args := client.Mock.Called(ctx, volumeID)
|
||||
return args.Get(0).(types.Volume), args.Error(1)
|
||||
}
|
||||
|
||||
// VolumeList returns the volumes configured in the docker host
|
||||
func (client *MockClient) VolumeList(filter filters.Args) (types.VolumesListResponse, error) {
|
||||
args := client.Mock.Called(filter)
|
||||
func (client *MockClient) VolumeList(ctx context.Context, filter filters.Args) (types.VolumesListResponse, error) {
|
||||
args := client.Mock.Called(ctx, filter)
|
||||
return args.Get(0).(types.VolumesListResponse), args.Error(1)
|
||||
}
|
||||
|
||||
// VolumeRemove removes a volume from the docker host
|
||||
func (client *MockClient) VolumeRemove(volumeID string) error {
|
||||
args := client.Mock.Called(volumeID)
|
||||
func (client *MockClient) VolumeRemove(ctx context.Context, volumeID string) error {
|
||||
args := client.Mock.Called(ctx, volumeID)
|
||||
return args.Error(0)
|
||||
}
|
||||
|
|
|
@ -4,15 +4,18 @@ import (
|
|||
"reflect"
|
||||
"testing"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
|
||||
"github.com/docker/engine-api/client"
|
||||
"github.com/docker/engine-api/types"
|
||||
"github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
func TestMock(t *testing.T) {
|
||||
mock := NewMockClient()
|
||||
mock.On("ServerVersion").Return(types.Version{Version: "foo"}, nil).Once()
|
||||
mockClient := NewMockClient()
|
||||
mockClient.On("ServerVersion", mock.Anything).Return(types.Version{Version: "foo"}, nil).Once()
|
||||
|
||||
v, err := mock.ServerVersion()
|
||||
v, err := mockClient.ServerVersion(context.TODO())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -20,14 +23,14 @@ func TestMock(t *testing.T) {
|
|||
t.Fatal(v)
|
||||
}
|
||||
|
||||
mock.Mock.AssertExpectations(t)
|
||||
mockClient.Mock.AssertExpectations(t)
|
||||
}
|
||||
|
||||
func TestMockInterface(t *testing.T) {
|
||||
iface := reflect.TypeOf((*client.APIClient)(nil)).Elem()
|
||||
mock := NewMockClient()
|
||||
mockClient := NewMockClient()
|
||||
|
||||
if !reflect.TypeOf(mock).Implements(iface) {
|
||||
if !reflect.TypeOf(mockClient).Implements(iface) {
|
||||
t.Fatalf("Mock does not implement the APIClient interface")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,47 +33,47 @@ func (client *NopClient) ClientVersion() string {
|
|||
}
|
||||
|
||||
// ContainerAttach attaches a connection to a container in the server
|
||||
func (client *NopClient) ContainerAttach(options types.ContainerAttachOptions) (types.HijackedResponse, error) {
|
||||
func (client *NopClient) ContainerAttach(ctx context.Context, options types.ContainerAttachOptions) (types.HijackedResponse, error) {
|
||||
return types.HijackedResponse{}, errNoEngine
|
||||
}
|
||||
|
||||
// ContainerCommit applies changes into a container and creates a new tagged image
|
||||
func (client *NopClient) ContainerCommit(options types.ContainerCommitOptions) (types.ContainerCommitResponse, error) {
|
||||
func (client *NopClient) ContainerCommit(ctx context.Context, options types.ContainerCommitOptions) (types.ContainerCommitResponse, error) {
|
||||
return types.ContainerCommitResponse{}, errNoEngine
|
||||
}
|
||||
|
||||
// ContainerCreate creates a new container based in the given configuration
|
||||
func (client *NopClient) ContainerCreate(config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, containerName string) (types.ContainerCreateResponse, error) {
|
||||
func (client *NopClient) ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, containerName string) (types.ContainerCreateResponse, error) {
|
||||
return types.ContainerCreateResponse{}, errNoEngine
|
||||
}
|
||||
|
||||
// ContainerDiff shows differences in a container filesystem since it was started
|
||||
func (client *NopClient) ContainerDiff(containerID string) ([]types.ContainerChange, error) {
|
||||
func (client *NopClient) ContainerDiff(ctx context.Context, containerID string) ([]types.ContainerChange, error) {
|
||||
return nil, errNoEngine
|
||||
}
|
||||
|
||||
// ContainerExecAttach attaches a connection to an exec process in the server
|
||||
func (client *NopClient) ContainerExecAttach(execID string, config types.ExecConfig) (types.HijackedResponse, error) {
|
||||
func (client *NopClient) ContainerExecAttach(ctx context.Context, execID string, config types.ExecConfig) (types.HijackedResponse, error) {
|
||||
return types.HijackedResponse{}, errNoEngine
|
||||
}
|
||||
|
||||
// ContainerExecCreate creates a new exec configuration to run an exec process
|
||||
func (client *NopClient) ContainerExecCreate(config types.ExecConfig) (types.ContainerExecCreateResponse, error) {
|
||||
func (client *NopClient) ContainerExecCreate(ctx context.Context, config types.ExecConfig) (types.ContainerExecCreateResponse, error) {
|
||||
return types.ContainerExecCreateResponse{}, errNoEngine
|
||||
}
|
||||
|
||||
// ContainerExecInspect returns information about a specific exec process on the docker host
|
||||
func (client *NopClient) ContainerExecInspect(execID string) (types.ContainerExecInspect, error) {
|
||||
func (client *NopClient) ContainerExecInspect(ctx context.Context, execID string) (types.ContainerExecInspect, error) {
|
||||
return types.ContainerExecInspect{}, errNoEngine
|
||||
}
|
||||
|
||||
// ContainerExecResize changes the size of the tty for an exec process running inside a container
|
||||
func (client *NopClient) ContainerExecResize(options types.ResizeOptions) error {
|
||||
func (client *NopClient) ContainerExecResize(ctx context.Context, options types.ResizeOptions) error {
|
||||
return errNoEngine
|
||||
}
|
||||
|
||||
// ContainerExecStart starts an exec process already create in the docker host
|
||||
func (client *NopClient) ContainerExecStart(execID string, config types.ExecStartCheck) error {
|
||||
func (client *NopClient) ContainerExecStart(ctx context.Context, execID string, config types.ExecStartCheck) error {
|
||||
return errNoEngine
|
||||
}
|
||||
|
||||
|
@ -83,22 +83,22 @@ func (client *NopClient) ContainerExport(ctx context.Context, containerID string
|
|||
}
|
||||
|
||||
// ContainerInspect returns the container information
|
||||
func (client *NopClient) ContainerInspect(containerID string) (types.ContainerJSON, error) {
|
||||
func (client *NopClient) ContainerInspect(ctx context.Context, containerID string) (types.ContainerJSON, error) {
|
||||
return types.ContainerJSON{}, errNoEngine
|
||||
}
|
||||
|
||||
// ContainerInspectWithRaw returns the container information and its raw representation
|
||||
func (client *NopClient) ContainerInspectWithRaw(containerID string, getSize bool) (types.ContainerJSON, []byte, error) {
|
||||
func (client *NopClient) ContainerInspectWithRaw(ctx context.Context, containerID string, getSize bool) (types.ContainerJSON, []byte, error) {
|
||||
return types.ContainerJSON{}, nil, errNoEngine
|
||||
}
|
||||
|
||||
// ContainerKill terminates the container process but does not remove the container from the docker host
|
||||
func (client *NopClient) ContainerKill(containerID, signal string) error {
|
||||
func (client *NopClient) ContainerKill(ctx context.Context, containerID, signal string) error {
|
||||
return errNoEngine
|
||||
}
|
||||
|
||||
// ContainerList returns the list of containers in the docker host
|
||||
func (client *NopClient) ContainerList(options types.ContainerListOptions) ([]types.Container, error) {
|
||||
func (client *NopClient) ContainerList(ctx context.Context, options types.ContainerListOptions) ([]types.Container, error) {
|
||||
return nil, errNoEngine
|
||||
}
|
||||
|
||||
|
@ -108,32 +108,32 @@ func (client *NopClient) ContainerLogs(ctx context.Context, options types.Contai
|
|||
}
|
||||
|
||||
// ContainerPause pauses the main process of a given container without terminating it
|
||||
func (client *NopClient) ContainerPause(containerID string) error {
|
||||
func (client *NopClient) ContainerPause(ctx context.Context, containerID string) error {
|
||||
return errNoEngine
|
||||
}
|
||||
|
||||
// ContainerRemove kills and removes a container from the docker host
|
||||
func (client *NopClient) ContainerRemove(options types.ContainerRemoveOptions) error {
|
||||
func (client *NopClient) ContainerRemove(ctx context.Context, options types.ContainerRemoveOptions) error {
|
||||
return errNoEngine
|
||||
}
|
||||
|
||||
// ContainerRename changes the name of a given container
|
||||
func (client *NopClient) ContainerRename(containerID, newContainerName string) error {
|
||||
func (client *NopClient) ContainerRename(ctx context.Context, containerID, newContainerName string) error {
|
||||
return errNoEngine
|
||||
}
|
||||
|
||||
// ContainerResize changes the size of the tty for a container
|
||||
func (client *NopClient) ContainerResize(options types.ResizeOptions) error {
|
||||
func (client *NopClient) ContainerResize(ctx context.Context, options types.ResizeOptions) error {
|
||||
return errNoEngine
|
||||
}
|
||||
|
||||
// ContainerRestart stops and starts a container again
|
||||
func (client *NopClient) ContainerRestart(containerID string, timeout int) error {
|
||||
func (client *NopClient) ContainerRestart(ctx context.Context, containerID string, timeout int) error {
|
||||
return errNoEngine
|
||||
}
|
||||
|
||||
// ContainerStatPath returns Stat information about a path inside the container filesystem
|
||||
func (client *NopClient) ContainerStatPath(containerID, path string) (types.ContainerPathStat, error) {
|
||||
func (client *NopClient) ContainerStatPath(ctx context.Context, containerID, path string) (types.ContainerPathStat, error) {
|
||||
return types.ContainerPathStat{}, errNoEngine
|
||||
}
|
||||
|
||||
|
@ -143,27 +143,27 @@ func (client *NopClient) ContainerStats(ctx context.Context, containerID string,
|
|||
}
|
||||
|
||||
// ContainerStart sends a request to the docker daemon to start a container
|
||||
func (client *NopClient) ContainerStart(containerID string) error {
|
||||
func (client *NopClient) ContainerStart(ctx context.Context, containerID string) error {
|
||||
return errNoEngine
|
||||
}
|
||||
|
||||
// ContainerStop stops a container without terminating the process
|
||||
func (client *NopClient) ContainerStop(containerID string, timeout int) error {
|
||||
func (client *NopClient) ContainerStop(ctx context.Context, containerID string, timeout int) error {
|
||||
return errNoEngine
|
||||
}
|
||||
|
||||
// ContainerTop shows process information from within a container
|
||||
func (client *NopClient) ContainerTop(containerID string, arguments []string) (types.ContainerProcessList, error) {
|
||||
func (client *NopClient) ContainerTop(ctx context.Context, containerID string, arguments []string) (types.ContainerProcessList, error) {
|
||||
return types.ContainerProcessList{}, errNoEngine
|
||||
}
|
||||
|
||||
// ContainerUnpause resumes the process execution within a container
|
||||
func (client *NopClient) ContainerUnpause(containerID string) error {
|
||||
func (client *NopClient) ContainerUnpause(ctx context.Context, containerID string) error {
|
||||
return errNoEngine
|
||||
}
|
||||
|
||||
// ContainerUpdate updates resources of a container
|
||||
func (client *NopClient) ContainerUpdate(containerID string, updateConfig container.UpdateConfig) error {
|
||||
func (client *NopClient) ContainerUpdate(ctx context.Context, containerID string, updateConfig container.UpdateConfig) error {
|
||||
return errNoEngine
|
||||
}
|
||||
|
||||
|
@ -198,7 +198,7 @@ func (client *NopClient) ImageCreate(ctx context.Context, options types.ImageCre
|
|||
}
|
||||
|
||||
// ImageHistory returns the changes in an image in history format
|
||||
func (client *NopClient) ImageHistory(imageID string) ([]types.ImageHistory, error) {
|
||||
func (client *NopClient) ImageHistory(ctx context.Context, imageID string) ([]types.ImageHistory, error) {
|
||||
return nil, errNoEngine
|
||||
}
|
||||
|
||||
|
@ -208,12 +208,12 @@ func (client *NopClient) ImageImport(ctx context.Context, options types.ImageImp
|
|||
}
|
||||
|
||||
// ImageInspectWithRaw returns the image information and it's raw representation
|
||||
func (client *NopClient) ImageInspectWithRaw(imageID string, getSize bool) (types.ImageInspect, []byte, error) {
|
||||
func (client *NopClient) ImageInspectWithRaw(ctx context.Context, imageID string, getSize bool) (types.ImageInspect, []byte, error) {
|
||||
return types.ImageInspect{}, nil, errNoEngine
|
||||
}
|
||||
|
||||
// ImageList returns a list of images in the docker host
|
||||
func (client *NopClient) ImageList(options types.ImageListOptions) ([]types.Image, error) {
|
||||
func (client *NopClient) ImageList(ctx context.Context, options types.ImageListOptions) ([]types.Image, error) {
|
||||
return nil, errNoEngine
|
||||
}
|
||||
|
||||
|
@ -233,12 +233,12 @@ func (client *NopClient) ImagePush(ctx context.Context, options types.ImagePushO
|
|||
}
|
||||
|
||||
// ImageRemove removes an image from the docker host
|
||||
func (client *NopClient) ImageRemove(options types.ImageRemoveOptions) ([]types.ImageDelete, error) {
|
||||
func (client *NopClient) ImageRemove(ctx context.Context, options types.ImageRemoveOptions) ([]types.ImageDelete, error) {
|
||||
return nil, errNoEngine
|
||||
}
|
||||
|
||||
// ImageSearch makes the docker host to search by a term in a remote registry
|
||||
func (client *NopClient) ImageSearch(options types.ImageSearchOptions, privilegeFunc client.RequestPrivilegeFunc) ([]registry.SearchResult, error) {
|
||||
func (client *NopClient) ImageSearch(ctx context.Context, options types.ImageSearchOptions, privilegeFunc client.RequestPrivilegeFunc) ([]registry.SearchResult, error) {
|
||||
return nil, errNoEngine
|
||||
}
|
||||
|
||||
|
@ -248,71 +248,71 @@ func (client *NopClient) ImageSave(ctx context.Context, imageIDs []string) (io.R
|
|||
}
|
||||
|
||||
// ImageTag tags an image in the docker host
|
||||
func (client *NopClient) ImageTag(options types.ImageTagOptions) error {
|
||||
func (client *NopClient) ImageTag(ctx context.Context, options types.ImageTagOptions) error {
|
||||
return errNoEngine
|
||||
}
|
||||
|
||||
// Info returns information about the docker server
|
||||
func (client *NopClient) Info() (types.Info, error) {
|
||||
func (client *NopClient) Info(ctx context.Context) (types.Info, error) {
|
||||
return types.Info{}, errNoEngine
|
||||
}
|
||||
|
||||
// NetworkConnect connects a container to an existent network in the docker host
|
||||
func (client *NopClient) NetworkConnect(networkID, containerID string, config *network.EndpointSettings) error {
|
||||
func (client *NopClient) NetworkConnect(ctx context.Context, networkID, containerID string, config *network.EndpointSettings) error {
|
||||
return errNoEngine
|
||||
}
|
||||
|
||||
// NetworkCreate creates a new network in the docker host
|
||||
func (client *NopClient) NetworkCreate(options types.NetworkCreate) (types.NetworkCreateResponse, error) {
|
||||
func (client *NopClient) NetworkCreate(ctx context.Context, options types.NetworkCreate) (types.NetworkCreateResponse, error) {
|
||||
return types.NetworkCreateResponse{}, errNoEngine
|
||||
}
|
||||
|
||||
// NetworkDisconnect disconnects a container from an existent network in the docker host
|
||||
func (client *NopClient) NetworkDisconnect(networkID, containerID string, force bool) error {
|
||||
func (client *NopClient) NetworkDisconnect(ctx context.Context, networkID, containerID string, force bool) error {
|
||||
return errNoEngine
|
||||
}
|
||||
|
||||
// NetworkInspect returns the information for a specific network configured in the docker host
|
||||
func (client *NopClient) NetworkInspect(networkID string) (types.NetworkResource, error) {
|
||||
func (client *NopClient) NetworkInspect(ctx context.Context, networkID string) (types.NetworkResource, error) {
|
||||
return types.NetworkResource{}, errNoEngine
|
||||
}
|
||||
|
||||
// NetworkList returns the list of networks configured in the docker host
|
||||
func (client *NopClient) NetworkList(options types.NetworkListOptions) ([]types.NetworkResource, error) {
|
||||
func (client *NopClient) NetworkList(ctx context.Context, options types.NetworkListOptions) ([]types.NetworkResource, error) {
|
||||
return nil, errNoEngine
|
||||
}
|
||||
|
||||
// NetworkRemove removes an existent network from the docker host
|
||||
func (client *NopClient) NetworkRemove(networkID string) error {
|
||||
func (client *NopClient) NetworkRemove(ctx context.Context, networkID string) error {
|
||||
return errNoEngine
|
||||
}
|
||||
|
||||
// RegistryLogin authenticates the docker server with a given docker registry
|
||||
func (client *NopClient) RegistryLogin(auth types.AuthConfig) (types.AuthResponse, error) {
|
||||
func (client *NopClient) RegistryLogin(ctx context.Context, auth types.AuthConfig) (types.AuthResponse, error) {
|
||||
return types.AuthResponse{}, errNoEngine
|
||||
}
|
||||
|
||||
// ServerVersion returns information of the docker client and server host
|
||||
func (client *NopClient) ServerVersion() (types.Version, error) {
|
||||
func (client *NopClient) ServerVersion(ctx context.Context) (types.Version, error) {
|
||||
return types.Version{}, errNoEngine
|
||||
}
|
||||
|
||||
// VolumeCreate creates a volume in the docker host
|
||||
func (client *NopClient) VolumeCreate(options types.VolumeCreateRequest) (types.Volume, error) {
|
||||
func (client *NopClient) VolumeCreate(ctx context.Context, options types.VolumeCreateRequest) (types.Volume, error) {
|
||||
return types.Volume{}, errNoEngine
|
||||
}
|
||||
|
||||
// VolumeInspect returns the information about a specific volume in the docker host
|
||||
func (client *NopClient) VolumeInspect(volumeID string) (types.Volume, error) {
|
||||
func (client *NopClient) VolumeInspect(ctx context.Context, volumeID string) (types.Volume, error) {
|
||||
return types.Volume{}, errNoEngine
|
||||
}
|
||||
|
||||
// VolumeList returns the volumes configured in the docker host
|
||||
func (client *NopClient) VolumeList(filter filters.Args) (types.VolumesListResponse, error) {
|
||||
func (client *NopClient) VolumeList(ctx context.Context, filter filters.Args) (types.VolumesListResponse, error) {
|
||||
return types.VolumesListResponse{}, errNoEngine
|
||||
}
|
||||
|
||||
// VolumeRemove removes a volume from the docker host
|
||||
func (client *NopClient) VolumeRemove(volumeID string) error {
|
||||
func (client *NopClient) VolumeRemove(ctx context.Context, volumeID string) error {
|
||||
return errNoEngine
|
||||
}
|
||||
|
|
|
@ -4,12 +4,14 @@ import (
|
|||
"reflect"
|
||||
"testing"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
|
||||
"github.com/docker/engine-api/client"
|
||||
)
|
||||
|
||||
func TestNop(t *testing.T) {
|
||||
nop := NewNopClient()
|
||||
_, err := nop.Info()
|
||||
_, err := nop.Info(context.TODO())
|
||||
if err != errNoEngine {
|
||||
t.Fatalf("Nop client did not return error")
|
||||
}
|
||||
|
|
|
@ -13,6 +13,8 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
|
||||
log "github.com/Sirupsen/logrus"
|
||||
"github.com/docker/docker/pkg/version"
|
||||
engineapi "github.com/docker/engine-api/client"
|
||||
|
@ -411,7 +413,7 @@ func (e *Engine) CheckConnectionErr(err error) {
|
|||
|
||||
// Gather engine specs (CPU, memory, constraints, ...).
|
||||
func (e *Engine) updateSpecs() error {
|
||||
info, err := e.apiClient.Info()
|
||||
info, err := e.apiClient.Info(context.TODO())
|
||||
e.CheckConnectionErr(err)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -421,7 +423,7 @@ func (e *Engine) updateSpecs() error {
|
|||
return fmt.Errorf("cannot get resources for this engine, make sure %s is a Docker Engine, not a Swarm manager", e.Addr)
|
||||
}
|
||||
|
||||
v, err := e.apiClient.ServerVersion()
|
||||
v, err := e.apiClient.ServerVersion(context.TODO())
|
||||
e.CheckConnectionErr(err)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -115,7 +115,7 @@ func TestEngineConnectionFailure(t *testing.T) {
|
|||
// Always fail.
|
||||
client := mockclient.NewMockClient()
|
||||
apiClient := engineapimock.NewMockClient()
|
||||
apiClient.On("Info").Return(types.Info{}, errors.New("fail"))
|
||||
apiClient.On("Info", mock.Anything).Return(types.Info{}, errors.New("fail"))
|
||||
|
||||
// Connect() should fail
|
||||
assert.Error(t, engine.ConnectWithClient(client, apiClient))
|
||||
|
@ -134,7 +134,7 @@ func TestOutdatedEngine(t *testing.T) {
|
|||
engine := NewEngine("test", 0, engOpts)
|
||||
client := mockclient.NewMockClient()
|
||||
apiClient := engineapimock.NewMockClient()
|
||||
apiClient.On("Info").Return(types.Info{}, nil)
|
||||
apiClient.On("Info", mock.Anything).Return(types.Info{}, nil)
|
||||
|
||||
assert.Error(t, engine.ConnectWithClient(client, apiClient))
|
||||
|
||||
|
@ -154,8 +154,8 @@ func TestEngineCpusMemory(t *testing.T) {
|
|||
|
||||
client := mockclient.NewMockClient()
|
||||
apiClient := engineapimock.NewMockClient()
|
||||
apiClient.On("Info").Return(mockInfo, nil)
|
||||
apiClient.On("ServerVersion").Return(mockVersion, nil)
|
||||
apiClient.On("Info", mock.Anything).Return(mockInfo, nil)
|
||||
apiClient.On("ServerVersion", mock.Anything).Return(mockVersion, nil)
|
||||
client.On("ListContainers", true, false, "").Return([]dockerclient.Container{}, nil)
|
||||
client.On("ListImages", mock.Anything).Return([]*dockerclient.Image{}, nil)
|
||||
client.On("ListVolumes", mock.Anything).Return([]*dockerclient.Volume{}, nil)
|
||||
|
@ -180,8 +180,8 @@ func TestEngineSpecs(t *testing.T) {
|
|||
|
||||
client := mockclient.NewMockClient()
|
||||
apiClient := engineapimock.NewMockClient()
|
||||
apiClient.On("Info").Return(mockInfo, nil)
|
||||
apiClient.On("ServerVersion").Return(mockVersion, nil)
|
||||
apiClient.On("Info", mock.Anything).Return(mockInfo, nil)
|
||||
apiClient.On("ServerVersion", mock.Anything).Return(mockVersion, nil)
|
||||
client.On("ListContainers", true, false, "").Return([]dockerclient.Container{}, nil)
|
||||
client.On("ListImages", mock.Anything).Return([]*dockerclient.Image{}, nil)
|
||||
client.On("ListVolumes", mock.Anything).Return([]*dockerclient.Volume{}, nil)
|
||||
|
@ -211,8 +211,8 @@ func TestEngineState(t *testing.T) {
|
|||
|
||||
client := mockclient.NewMockClient()
|
||||
apiClient := engineapimock.NewMockClient()
|
||||
apiClient.On("Info").Return(mockInfo, nil)
|
||||
apiClient.On("ServerVersion").Return(mockVersion, nil)
|
||||
apiClient.On("Info", mock.Anything).Return(mockInfo, nil)
|
||||
apiClient.On("ServerVersion", mock.Anything).Return(mockVersion, nil)
|
||||
client.On("StartMonitorEvents", mock.Anything, mock.Anything, mock.Anything).Return()
|
||||
|
||||
// The client will return one container at first, then a second one will appear.
|
||||
|
@ -263,8 +263,8 @@ func TestCreateContainer(t *testing.T) {
|
|||
)
|
||||
|
||||
engine.setState(stateUnhealthy)
|
||||
apiClient.On("Info").Return(mockInfo, nil)
|
||||
apiClient.On("ServerVersion").Return(mockVersion, nil)
|
||||
apiClient.On("Info", mock.Anything).Return(mockInfo, nil)
|
||||
apiClient.On("ServerVersion", mock.Anything).Return(mockVersion, nil)
|
||||
client.On("StartMonitorEvents", mock.Anything, mock.Anything, mock.Anything).Return()
|
||||
client.On("ListContainers", true, false, "").Return([]dockerclient.Container{}, nil).Once()
|
||||
client.On("ListImages", mock.Anything).Return([]*dockerclient.Image{}, nil).Once()
|
||||
|
@ -369,8 +369,8 @@ func TestUsedCpus(t *testing.T) {
|
|||
mockInfo.NCPU = hn
|
||||
cpuShares := int64(math.Ceil(float64(cn*1024) / float64(mockInfo.NCPU)))
|
||||
|
||||
apiClient.On("Info").Return(mockInfo, nil).Once()
|
||||
apiClient.On("ServerVersion").Return(mockVersion, nil)
|
||||
apiClient.On("Info", mock.Anything).Return(mockInfo, nil).Once()
|
||||
apiClient.On("ServerVersion", mock.Anything).Return(mockVersion, nil)
|
||||
client.On("StartMonitorEvents", mock.Anything, mock.Anything, mock.Anything).Return()
|
||||
client.On("ListImages", mock.Anything).Return([]*dockerclient.Image{}, nil).Once()
|
||||
client.On("ListContainers", true, false, "").Return([]dockerclient.Container{{Id: "test"}}, nil).Once()
|
||||
|
@ -403,8 +403,8 @@ func TestContainerRemovedDuringRefresh(t *testing.T) {
|
|||
client := mockclient.NewMockClient()
|
||||
apiClient := engineapimock.NewMockClient()
|
||||
|
||||
apiClient.On("Info").Return(mockInfo, nil)
|
||||
apiClient.On("ServerVersion").Return(mockVersion, nil)
|
||||
apiClient.On("Info", mock.Anything).Return(mockInfo, nil)
|
||||
apiClient.On("ServerVersion", mock.Anything).Return(mockVersion, nil)
|
||||
client.On("ListImages", mock.Anything).Return([]*dockerclient.Image{}, nil)
|
||||
client.On("StartMonitorEvents", mock.Anything, mock.Anything, mock.Anything).Return()
|
||||
client.On("ListContainers", true, false, "").Return([]dockerclient.Container{container1, container2}, nil)
|
||||
|
@ -431,8 +431,8 @@ func TestDisconnect(t *testing.T) {
|
|||
client := mockclient.NewMockClient()
|
||||
apiClient := engineapimock.NewMockClient()
|
||||
|
||||
apiClient.On("Info").Return(mockInfo, nil)
|
||||
apiClient.On("ServerVersion").Return(mockVersion, nil)
|
||||
apiClient.On("Info", mock.Anything).Return(mockInfo, nil)
|
||||
apiClient.On("ServerVersion", mock.Anything).Return(mockVersion, nil)
|
||||
client.On("StartMonitorEvents", mock.Anything, mock.Anything, mock.Anything).Return()
|
||||
client.On("StopAllMonitorEvents", mock.Anything, mock.Anything, mock.Anything).Return()
|
||||
|
||||
|
|
|
@ -135,8 +135,8 @@ func TestImportImage(t *testing.T) {
|
|||
// create mock client
|
||||
client := mockclient.NewMockClient()
|
||||
apiClient := engineapimock.NewMockClient()
|
||||
apiClient.On("Info").Return(mockInfo, nil)
|
||||
apiClient.On("ServerVersion").Return(mockVersion, nil)
|
||||
apiClient.On("Info", mock.Anything).Return(mockInfo, nil)
|
||||
apiClient.On("ServerVersion", mock.Anything).Return(mockVersion, nil)
|
||||
client.On("StartMonitorEvents", mock.Anything, mock.Anything, mock.Anything).Return()
|
||||
client.On("ListContainers", true, false, "").Return([]dockerclient.Container{}, nil).Once()
|
||||
client.On("ListImages", mock.Anything).Return([]*dockerclient.Image{}, nil)
|
||||
|
@ -186,8 +186,8 @@ func TestLoadImage(t *testing.T) {
|
|||
// create mock client
|
||||
client := mockclient.NewMockClient()
|
||||
apiClient := engineapimock.NewMockClient()
|
||||
apiClient.On("Info").Return(mockInfo, nil)
|
||||
apiClient.On("ServerVersion").Return(mockVersion, nil)
|
||||
apiClient.On("Info", mock.Anything).Return(mockInfo, nil)
|
||||
apiClient.On("ServerVersion", mock.Anything).Return(mockVersion, nil)
|
||||
client.On("StartMonitorEvents", mock.Anything, mock.Anything, mock.Anything).Return()
|
||||
client.On("ListContainers", true, false, "").Return([]dockerclient.Container{}, nil).Once()
|
||||
client.On("ListImages", mock.Anything).Return([]*dockerclient.Image{}, nil)
|
||||
|
@ -240,8 +240,8 @@ func TestTagImage(t *testing.T) {
|
|||
// create mock client
|
||||
client := mockclient.NewMockClient()
|
||||
apiClient := engineapimock.NewMockClient()
|
||||
apiClient.On("Info").Return(mockInfo, nil)
|
||||
apiClient.On("ServerVersion").Return(mockVersion, nil)
|
||||
apiClient.On("Info", mock.Anything).Return(mockInfo, nil)
|
||||
apiClient.On("ServerVersion", mock.Anything).Return(mockVersion, nil)
|
||||
client.On("StartMonitorEvents", mock.Anything, mock.Anything, mock.Anything).Return()
|
||||
client.On("ListContainers", true, false, "").Return([]dockerclient.Container{}, nil).Once()
|
||||
client.On("ListImages", mock.Anything).Return(images, nil)
|
||||
|
|
Loading…
Reference in New Issue