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

Function TestClashWithGlobalArgs

e2e/cli-plugins/flags_test.go:25–69  ·  view source on GitHub ↗

TestClashWithGlobalArgs ensures correct behaviour when a plugin has an argument with the same name as one of the globals.

(t *testing.T)

Source from the content-addressed store, hash-verified

23// TestClashWithGlobalArgs ensures correct behaviour when a plugin
24// has an argument with the same name as one of the globals.
25func TestClashWithGlobalArgs(t *testing.T) {
26 run, _, cleanup := prepare(t)
27 defer cleanup()
28
29 for _, tc := range []struct {
30 name string
31 args []string
32 expectedOut, expectedErr string
33 }{
34 {
35 name: "short-without-val",
36 args: []string{"-D"},
37 expectedOut: "Hello World",
38 expectedErr: "Plugin debug mode enabled",
39 },
40 {
41 name: "long-without-val",
42 args: []string{"--debug"},
43 expectedOut: "Hello World",
44 expectedErr: "Plugin debug mode enabled",
45 },
46 {
47 name: "short-with-val",
48 args: []string{"-c", "Christmas"},
49 expectedOut: "Merry Christmas",
50 expectedErr: icmd.None,
51 },
52 {
53 name: "short-with-val",
54 args: []string{"--context", "Christmas"},
55 expectedOut: "Merry Christmas",
56 expectedErr: icmd.None,
57 },
58 } {
59 t.Run(tc.name, func(t *testing.T) {
60 args := append([]string{"helloworld"}, tc.args...)
61 res := icmd.RunCmd(run(args...))
62 res.Assert(t, icmd.Expected{
63 ExitCode: 0,
64 Out: tc.expectedOut,
65 Err: tc.expectedErr,
66 })
67 })
68 }
69}
70
71// TestGlobalArgsOnlyParsedOnce checks that global args are only parsed
72// once (cf https://github.com/docker/cli/issues/1801). These tests

Callers

nothing calls this directly

Calls 2

prepareFunction · 0.85
runFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…