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

Function TestNewImportCommandErrors

cli/command/image/import_test.go:15–43  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

13)
14
15func TestNewImportCommandErrors(t *testing.T) {
16 testCases := []struct {
17 name string
18 args []string
19 expectedError string
20 imageImportFunc func(source client.ImageImportSource, ref string, options client.ImageImportOptions) (client.ImageImportResult, error)
21 }{
22 {
23 name: "wrong-args",
24 args: []string{},
25 expectedError: "requires at least 1 argument",
26 },
27 {
28 name: "import-failed",
29 args: []string{"testdata/import-command-success.input.txt"},
30 expectedError: "something went wrong",
31 imageImportFunc: func(source client.ImageImportSource, ref string, options client.ImageImportOptions) (client.ImageImportResult, error) {
32 return nil, errors.New("something went wrong")
33 },
34 },
35 }
36 for _, tc := range testCases {
37 cmd := newImportCommand(test.NewFakeCli(&fakeClient{imageImportFunc: tc.imageImportFunc}))
38 cmd.SetOut(io.Discard)
39 cmd.SetErr(io.Discard)
40 cmd.SetArgs(tc.args)
41 assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
42 }
43}
44
45func TestNewImportCommandInvalidFile(t *testing.T) {
46 cmd := newImportCommand(test.NewFakeCli(&fakeClient{}))

Callers

nothing calls this directly

Calls 4

SetArgsMethod · 0.80
newImportCommandFunction · 0.70
SetOutMethod · 0.45
SetErrMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…