(t *testing.T)
| 256 | } |
| 257 | |
| 258 | func TestNewExecCommandErrors(t *testing.T) { |
| 259 | testCases := []struct { |
| 260 | name string |
| 261 | args []string |
| 262 | expectedError string |
| 263 | containerInspectFunc func(img string) (client.ContainerInspectResult, error) |
| 264 | }{ |
| 265 | { |
| 266 | name: "client-error", |
| 267 | args: []string{"5cb5bb5e4a3b", "-t", "-i", "bash"}, |
| 268 | expectedError: "something went wrong", |
| 269 | containerInspectFunc: func(containerID string) (client.ContainerInspectResult, error) { |
| 270 | return client.ContainerInspectResult{}, errors.New("something went wrong") |
| 271 | }, |
| 272 | }, |
| 273 | } |
| 274 | for _, tc := range testCases { |
| 275 | fakeCLI := test.NewFakeCli(&fakeClient{inspectFunc: tc.containerInspectFunc}) |
| 276 | cmd := newExecCommand(fakeCLI) |
| 277 | cmd.SetOut(io.Discard) |
| 278 | cmd.SetArgs(tc.args) |
| 279 | assert.ErrorContains(t, cmd.Execute(), tc.expectedError) |
| 280 | } |
| 281 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…