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

Function TestNewPushCommandSuccess

cli/command/image/push_test.go:57–93  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

55}
56
57func TestNewPushCommandSuccess(t *testing.T) {
58 testCases := []struct {
59 name string
60 args []string
61 output string
62 }{
63 {
64 name: "push",
65 args: []string{"image:tag"},
66 },
67 {
68 name: "push quiet",
69 args: []string{"--quiet", "image:tag"},
70 output: `docker.io/library/image:tag
71`,
72 },
73 }
74
75 for _, tc := range testCases {
76 t.Run(tc.name, func(t *testing.T) {
77 cli := test.NewFakeCli(&fakeClient{
78 imagePushFunc: func(ref string, options client.ImagePushOptions) (client.ImagePushResponse, error) {
79 // FIXME(thaJeztah): how to mock this?
80 return fakeStreamResult{ReadCloser: http.NoBody}, nil
81 },
82 })
83 cmd := newPushCommand(cli)
84 cmd.SetOut(cli.OutBuffer())
85 cmd.SetErr(io.Discard)
86 cmd.SetArgs(tc.args)
87 assert.NilError(t, cmd.Execute())
88 if tc.output != "" {
89 assert.Equal(t, tc.output, cli.OutBuffer().String())
90 }
91 })
92 }
93}
94
95func TestRunPushRespectsNoColorForAuxNotes(t *testing.T) {
96 t.Setenv("NO_COLOR", "1")

Callers

nothing calls this directly

Calls 6

OutBufferMethod · 0.95
SetArgsMethod · 0.80
newPushCommandFunction · 0.70
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…