MCPcopy Index your code
hub / github.com/docker/cli / TestNewExecCommandErrors

Function TestNewExecCommandErrors

cli/command/container/exec_test.go:258–281  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

256}
257
258func 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}

Callers

nothing calls this directly

Calls 3

newExecCommandFunction · 0.85
SetArgsMethod · 0.80
SetOutMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…