MCPcopy Create free account
hub / github.com/docker/docker-agent / TestCompleteAlias

Function TestCompleteAlias

cmd/root/completion_test.go:221–257  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

219}
220
221func TestCompleteAlias(t *testing.T) {
222 t.Parallel()
223
224 tests := []struct {
225 name string
226 toComplete string
227 wantFilesystem bool // if true, should delegate to filesystem completion
228 }{
229 {
230 name: "path starting with dot delegates to filesystem",
231 toComplete: "./agent",
232 wantFilesystem: true,
233 },
234 {
235 name: "path starting with slash delegates to filesystem",
236 toComplete: "/etc/agent",
237 wantFilesystem: true,
238 },
239 {
240 name: "plain text tries alias completion",
241 toComplete: "myalias",
242 wantFilesystem: false,
243 },
244 }
245
246 for _, tt := range tests {
247 t.Run(tt.name, func(t *testing.T) {
248 t.Parallel()
249
250 _, directive := completeAlias(tt.toComplete)
251
252 // Both paths should set NoFileComp
253 assert.NotEqual(t, cobra.ShellCompDirective(0), directive&cobra.ShellCompDirectiveNoFileComp,
254 "expected NoFileComp directive to be set")
255 })
256 }
257}
258
259func TestCompleteAliasIncludesYAMLFiles(t *testing.T) {
260 // This test changes the working directory so it cannot run in parallel

Callers

nothing calls this directly

Calls 2

completeAliasFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected