| 145 | } |
| 146 | |
| 147 | func TestDockerExecFailure(t *testing.T) { |
| 148 | ctx := context.Background() |
| 149 | |
| 150 | conn := &mockConn{} |
| 151 | |
| 152 | cli := &mockDockerClient{} |
| 153 | cli.On("ExecCreate", ctx, "123", mock.AnythingOfType("client.ExecCreateOptions")).Return(client.ExecCreateResult{ID: "id"}, nil) |
| 154 | cli.On("ExecAttach", ctx, "id", mock.AnythingOfType("client.ExecAttachOptions")).Return(client.ExecAttachResult{ |
| 155 | HijackedResponse: client.HijackedResponse{ |
| 156 | Conn: conn, |
| 157 | Reader: bufio.NewReader(strings.NewReader("output")), |
| 158 | }, |
| 159 | }, nil) |
| 160 | cli.On("ExecInspect", ctx, "id", mock.AnythingOfType("client.ExecInspectOptions")).Return(client.ExecInspectResult{ |
| 161 | ExitCode: 1, |
| 162 | }, nil) |
| 163 | |
| 164 | cr := &containerReference{ |
| 165 | id: "123", |
| 166 | cli: cli, |
| 167 | input: &NewContainerInput{ |
| 168 | Image: "image", |
| 169 | }, |
| 170 | } |
| 171 | |
| 172 | err := cr.exec([]string{""}, map[string]string{}, "user", "workdir")(ctx) |
| 173 | assert.Error(t, err, "exit with `FAILURE`: 1") |
| 174 | |
| 175 | conn.AssertExpectations(t) |
| 176 | cli.AssertExpectations(t) |
| 177 | } |
| 178 | |
| 179 | func TestDockerCopyTarStream(t *testing.T) { |
| 180 | ctx := context.Background() |