MCPcopy Create free account
hub / github.com/docker/cli / TestInspectValidateFlagsAndArgs

Function TestInspectValidateFlagsAndArgs

cli/command/system/inspect_test.go:12–48  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestInspectValidateFlagsAndArgs(t *testing.T) {
13 for _, tc := range []struct {
14 name string
15 args []string
16 expectedErr string
17 }{
18 {
19 name: "empty type",
20 args: []string{"--type", "", "something"},
21 expectedErr: `type is empty: must be one of "config", "container", "image", "network", "node", "plugin", "secret", "service", "task", "volume"`,
22 },
23 {
24 name: "unknown type",
25 args: []string{"--type", "unknown", "something"},
26 expectedErr: `unknown type: "unknown": must be one of "config", "container", "image", "network", "node", "plugin", "secret", "service", "task", "volume"`,
27 },
28 {
29 name: "no arg",
30 args: []string{},
31 expectedErr: `inspect: 'inspect' requires at least 1 argument`,
32 },
33 } {
34 t.Run(tc.name, func(t *testing.T) {
35 cmd := newInspectCommand(test.NewFakeCli(&fakeClient{}))
36 cmd.SetOut(io.Discard)
37 cmd.SetErr(io.Discard)
38 cmd.SetArgs(tc.args)
39
40 err := cmd.Execute()
41 if tc.expectedErr != "" {
42 assert.Check(t, is.ErrorContains(err, tc.expectedErr))
43 } else {
44 assert.Check(t, is.Nil(err))
45 }
46 })
47 }
48}

Callers

nothing calls this directly

Calls 4

SetArgsMethod · 0.80
newInspectCommandFunction · 0.70
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…