Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

(MAINT) Update ContainerExecAttach sig/mocks in tests

  • Loading branch information...
johnmccabe committed Oct 19, 2017
1 parent 0a3533f commit fac71b794780c7074a5da998f07b72a384d6411f
@@ -48,7 +48,7 @@ var runPackageCmdTests = []struct {
title: "Error attaching to exec",
mockHarvesterDockerClient: &mocks.MockDockerClient{
ContainerExecCreateFn: successfulContainerExecCreateFn,
ContainerExecAttachFn: func(ctx context.Context, execID string, cmd []string, attachStdout bool, attachStderr bool) (dockertypes.HijackedResponse, error) {
ContainerExecAttachFn: func(ctx context.Context, execID string) (dockertypes.HijackedResponse, error) {
return dockertypes.HijackedResponse{}, fmt.Errorf("Dummy ContainerExecAttach error")
},
},
@@ -15,8 +15,8 @@ func successfulContainerExecCreateFn(ctx context.Context, containerID string, cm
return mockIDResponse, nil
}

func createSuccesfulContainerExecAttachFn(buf []byte) func(context.Context, string, []string, bool, bool) (dockertypes.HijackedResponse, error) {
var succesfulContainerExecAttachFn = func(ctx context.Context, execID string, cmd []string, attachStdout bool, attachStderr bool) (dockertypes.HijackedResponse, error) {
func createSuccesfulContainerExecAttachFn(buf []byte) func(context.Context, string) (dockertypes.HijackedResponse, error) {
var succesfulContainerExecAttachFn = func(ctx context.Context, execID string) (dockertypes.HijackedResponse, error) {
mockHijackedResponse := dockertypes.HijackedResponse{}
mockHijackedResponse.Conn = mocks.MockNetConn{
CloseFn: func() error {
@@ -27,7 +27,7 @@ type MockDockerClient struct {
ContainerListFn func(ctx context.Context) ([]string, error)
ContainerExecCreateFn func(ctx context.Context, containerID string, cmd []string, attachStdout bool, attachStderr bool) (dockertypes.IDResponse, error)
ContainerExecStartFn func(ctx context.Context, execID string) error
ContainerExecAttachFn func(ctx context.Context, execID string, cmd []string, attachStdout bool, attachStderr bool) (dockertypes.HijackedResponse, error)
ContainerExecAttachFn func(ctx context.Context, execID string) (dockertypes.HijackedResponse, error)
ContainerExecInspectFn func(ctx context.Context, execID string) (dockertypes.ContainerExecInspect, error)
ImageInspectFn func(ctx context.Context, imageName string) (dockertypes.ImageInspect, error)
CopyFromContainerFn func(ctx context.Context, container, srcPath string, followSymlink bool) (io.ReadCloser, dockertypes.ContainerPathStat, error)
@@ -157,15 +157,12 @@ func (c *MockDockerClient) ContainerExecStart(ctx context.Context, execID string
}

// ContainerExecAttach is a mock implementation of dockeradapter.ContainerExecAttach
func (c *MockDockerClient) ContainerExecAttach(ctx context.Context, execID string, cmd []string, attachStdout bool, attachStderr bool) (dockertypes.HijackedResponse, error) {
func (c *MockDockerClient) ContainerExecAttach(ctx context.Context, execID string) (dockertypes.HijackedResponse, error) {
if c.ContainerExecAttachFn != nil {
fmt.Println("[MockDockerClient] In ", utils.CurrentFunctionName())
fmt.Println("[MockDockerClient] - ctx: ", ctx)
fmt.Println("[MockDockerClient] - execID: ", execID)
fmt.Println("[MockDockerClient] - cmd: ", cmd)
fmt.Println("[MockDockerClient] - attachStdout: ", attachStdout)
fmt.Println("[MockDockerClient] - attachStderr: ", attachStderr)
return c.ContainerExecAttachFn(ctx, execID, cmd, attachStdout, attachStderr)
return c.ContainerExecAttachFn(ctx, execID)
}
panic(fmt.Sprintf("No function defined for: %s", utils.CurrentFunctionName()))
}

0 comments on commit fac71b7

Please sign in to comment.
You can’t perform that action at this time.