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

Function TestRunValidateFlags

cli/command/container/run_test.go:24–55  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

22)
23
24func TestRunValidateFlags(t *testing.T) {
25 for _, tc := range []struct {
26 name string
27 args []string
28 expectedErr string
29 }{
30 {
31 name: "with conflicting --attach, --detach",
32 args: []string{"--attach", "stdin", "--detach", "myimage"},
33 expectedErr: "conflicting options: cannot specify both --attach and --detach",
34 },
35 {
36 name: "with invalid --detach-keys",
37 args: []string{"--detach-keys", "shift-a", "myimage"},
38 expectedErr: "invalid detach keys (shift-a):",
39 },
40 } {
41 t.Run(tc.name, func(t *testing.T) {
42 cmd := newRunCommand(test.NewFakeCli(&fakeClient{}))
43 cmd.SetOut(io.Discard)
44 cmd.SetErr(io.Discard)
45 cmd.SetArgs(tc.args)
46
47 err := cmd.Execute()
48 if tc.expectedErr != "" {
49 assert.Check(t, is.ErrorContains(err, tc.expectedErr))
50 } else {
51 assert.Check(t, is.Nil(err))
52 }
53 })
54 }
55}
56
57func TestRunLabel(t *testing.T) {
58 fakeCLI := test.NewFakeCli(&fakeClient{

Callers

nothing calls this directly

Calls 4

newRunCommandFunction · 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…