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

Function TestNewCreateCommandWithWarnings

cli/command/container/create_test.go:231–272  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

229}
230
231func TestNewCreateCommandWithWarnings(t *testing.T) {
232 testCases := []struct {
233 name string
234 args []string
235 warnings []string
236 warning bool
237 }{
238 {
239 name: "container-create-no-warnings",
240 args: []string{"image:tag"},
241 },
242 {
243 name: "container-create-daemon-single-warning",
244 args: []string{"image:tag"},
245 warnings: []string{"warning from daemon"},
246 },
247 {
248 name: "container-create-daemon-multiple-warnings",
249 args: []string{"image:tag"},
250 warnings: []string{"warning from daemon", "another warning from daemon"},
251 },
252 }
253 for _, tc := range testCases {
254 t.Run(tc.name, func(t *testing.T) {
255 fakeCLI := test.NewFakeCli(&fakeClient{
256 createContainerFunc: func(options client.ContainerCreateOptions) (client.ContainerCreateResult, error) {
257 return client.ContainerCreateResult{Warnings: tc.warnings}, nil
258 },
259 })
260 cmd := newCreateCommand(fakeCLI)
261 cmd.SetOut(io.Discard)
262 cmd.SetArgs(tc.args)
263 err := cmd.Execute()
264 assert.NilError(t, err)
265 if tc.warning || len(tc.warnings) > 0 {
266 golden.Assert(t, fakeCLI.ErrBuffer().String(), tc.name+".golden")
267 } else {
268 assert.Equal(t, fakeCLI.ErrBuffer().String(), "")
269 }
270 })
271 }
272}
273
274func TestCreateContainerWithProxyConfig(t *testing.T) {
275 expected := []string{

Callers

nothing calls this directly

Calls 5

ErrBufferMethod · 0.95
SetArgsMethod · 0.80
newCreateCommandFunction · 0.70
StringMethod · 0.65
SetOutMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…