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

Function TestNewPullCommandErrors

cli/command/image/pull_test.go:16–48  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

14)
15
16func TestNewPullCommandErrors(t *testing.T) {
17 testCases := []struct {
18 name string
19 args []string
20 expectedError string
21 }{
22 {
23 name: "wrong-args",
24 expectedError: "requires 1 argument",
25 args: []string{},
26 },
27 {
28 name: "invalid-name",
29 expectedError: "invalid reference format: repository name (library/UPPERCASE_REPO) must be lowercase",
30 args: []string{"UPPERCASE_REPO"},
31 },
32 {
33 name: "all-tags-with-tag",
34 expectedError: "tag can't be used with --all-tags/-a",
35 args: []string{"--all-tags", "image:tag"},
36 },
37 }
38 for _, tc := range testCases {
39 t.Run(tc.name, func(t *testing.T) {
40 cli := test.NewFakeCli(&fakeClient{})
41 cmd := newPullCommand(cli)
42 cmd.SetOut(io.Discard)
43 cmd.SetErr(io.Discard)
44 cmd.SetArgs(tc.args)
45 assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
46 })
47 }
48}
49
50func TestNewPullCommandSuccess(t *testing.T) {
51 testCases := []struct {

Callers

nothing calls this directly

Calls 4

newPullCommandFunction · 0.85
SetArgsMethod · 0.80
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…