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

Function TestCompleteSecurityOpt

cli/command/container/completion_test.go:79–130  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

77}
78
79func TestCompleteSecurityOpt(t *testing.T) {
80 tests := []struct {
81 toComplete string
82 expectedCompletions []string
83 expectedDirective cobra.ShellCompDirective
84 }{
85 {
86 toComplete: "",
87 expectedCompletions: []string{"apparmor=", "label=", "no-new-privileges", "seccomp=", "systempaths=unconfined"},
88 expectedDirective: cobra.ShellCompDirectiveNoFileComp,
89 },
90 {
91 toComplete: "apparmor=",
92 expectedCompletions: []string{"apparmor="},
93 expectedDirective: cobra.ShellCompDirectiveNoSpace,
94 },
95 {
96 toComplete: "label=",
97 expectedCompletions: []string{"label=disable", "label=level:", "label=role:", "label=type:", "label=user:"},
98 expectedDirective: cobra.ShellCompDirectiveNoSpace | cobra.ShellCompDirectiveNoFileComp,
99 },
100 {
101 toComplete: "s",
102 // We do not filter matching completions but delegate this task to the shell script.
103 expectedCompletions: []string{"apparmor=", "label=", "no-new-privileges", "seccomp=", "systempaths=unconfined"},
104 expectedDirective: cobra.ShellCompDirectiveNoFileComp,
105 },
106 {
107 toComplete: "se",
108 expectedCompletions: []string{"seccomp="},
109 expectedDirective: cobra.ShellCompDirectiveNoSpace,
110 },
111 {
112 toComplete: "seccomp=",
113 expectedCompletions: []string{"seccomp=unconfined"},
114 expectedDirective: cobra.ShellCompDirectiveNoFileComp,
115 },
116 {
117 toComplete: "sy",
118 expectedCompletions: []string{"apparmor=", "label=", "no-new-privileges", "seccomp=", "systempaths=unconfined"},
119 expectedDirective: cobra.ShellCompDirectiveNoFileComp,
120 },
121 }
122
123 for _, tc := range tests {
124 t.Run(tc.toComplete, func(t *testing.T) {
125 completions, directive := completeSecurityOpt(nil, nil, tc.toComplete)
126 assert.Check(t, is.DeepEqual(completions, tc.expectedCompletions))
127 assert.Check(t, is.Equal(directive, tc.expectedDirective))
128 })
129 }
130}
131
132func TestCompleteSignals(t *testing.T) {
133 values, directives := completeSignals(nil, nil, "")

Callers

nothing calls this directly

Calls 1

completeSecurityOptFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…