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

Function TestPluginStubCompletionRestoresOSArgs

cli-plugins/manager/cobra_test.go:40–53  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

38}
39
40func TestPluginStubCompletionRestoresOSArgs(t *testing.T) {
41 cmd, err := preparePluginStubCommand(t)
42 assert.NilError(t, err)
43
44 savedArgs := os.Args
45 t.Cleanup(func() { os.Args = savedArgs })
46
47 originalArgs := []string{"docker", "image", "ls"}
48 os.Args = append([]string(nil), originalArgs...)
49
50 _, directive := cmd.ValidArgsFunction(cmd, []string{"--all"}, "alp")
51 assert.Equal(t, directive, cobra.ShellCompDirectiveError)
52 assert.DeepEqual(t, os.Args, originalArgs)
53}
54
55func preparePluginStubCommand(t *testing.T) (*cobra.Command, error) {
56 t.Helper()

Callers

nothing calls this directly

Calls 1

preparePluginStubCommandFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…