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

Function TestNewPullCommandSuccess

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

Source from the content-addressed store, hash-verified

48}
49
50func TestNewPullCommandSuccess(t *testing.T) {
51 testCases := []struct {
52 name string
53 args []string
54 expectedTag string
55 }{
56 {
57 name: "simple",
58 args: []string{"image:tag"},
59 expectedTag: "image:tag",
60 },
61 {
62 name: "simple-no-tag",
63 args: []string{"image"},
64 expectedTag: "image:latest",
65 },
66 {
67 name: "simple-quiet",
68 args: []string{"--quiet", "image"},
69 expectedTag: "image:latest",
70 },
71 }
72 for _, tc := range testCases {
73 t.Run(tc.name, func(t *testing.T) {
74 cli := test.NewFakeCli(&fakeClient{
75 imagePullFunc: func(ref string, options client.ImagePullOptions) (client.ImagePullResponse, error) {
76 assert.Check(t, is.Equal(tc.expectedTag, ref), tc.name)
77 // FIXME(thaJeztah): how to mock this?
78 return fakeStreamResult{ReadCloser: http.NoBody}, nil
79 },
80 })
81 cmd := newPullCommand(cli)
82 cmd.SetOut(io.Discard)
83 cmd.SetErr(io.Discard)
84 cmd.SetArgs(tc.args)
85 err := cmd.Execute()
86 assert.NilError(t, err)
87 golden.Assert(t, cli.OutBuffer().String(), fmt.Sprintf("pull-command-success.%s.golden", tc.name))
88 })
89 }
90}

Callers

nothing calls this directly

Calls 6

OutBufferMethod · 0.95
newPullCommandFunction · 0.85
SetArgsMethod · 0.80
StringMethod · 0.65
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…