| 43 | } |
| 44 | |
| 45 | func TestRunKillClientError(t *testing.T) { |
| 46 | cli := test.NewFakeCli(&fakeClient{ |
| 47 | containerKillFunc: func(ctx context.Context, container string, options client.ContainerKillOptions) (client.ContainerKillResult, error) { |
| 48 | return client.ContainerKillResult{}, fmt.Errorf("client error for container %s", container) |
| 49 | }, |
| 50 | }) |
| 51 | |
| 52 | cmd := newKillCommand(cli) |
| 53 | cmd.SetOut(io.Discard) |
| 54 | cmd.SetErr(io.Discard) |
| 55 | |
| 56 | cmd.SetArgs([]string{"container-id-1", "container-id-2"}) |
| 57 | err := cmd.Execute() |
| 58 | |
| 59 | errs := strings.SplitN(err.Error(), "\n", 2) |
| 60 | assert.Assert(t, is.Len(errs, 2)) |
| 61 | |
| 62 | errContainerID1 := errs[0] |
| 63 | errContainerID2 := errs[1] |
| 64 | |
| 65 | assert.Assert(t, is.Equal(errContainerID1, "client error for container container-id-1")) |
| 66 | assert.Assert(t, is.Equal(errContainerID2, "client error for container container-id-2")) |
| 67 | } |