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

Function TestCompleteAliasIncludesYAMLFiles

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

Source from the content-addressed store, hash-verified

257}
258
259func TestCompleteAliasIncludesYAMLFiles(t *testing.T) {
260 // This test changes the working directory so it cannot run in parallel
261
262 // Create temp directory with YAML files
263 tmpDir := t.TempDir()
264 writeFile(t, tmpDir, "golang_developer.yaml")
265 writeFile(t, tmpDir, "gopher.yaml")
266 writeFile(t, tmpDir, "other.yaml")
267 writeFile(t, tmpDir, "readme.md") // not a yaml file
268
269 // Change working directory
270 t.Chdir(tmpDir)
271
272 // Test that completeAlias includes YAML files starting with "go"
273 completions, directive := completeAlias("go")
274
275 // Should include yaml files matching "go" prefix
276 assert.Contains(t, completions, "golang_developer.yaml")
277 assert.Contains(t, completions, "gopher.yaml")
278 assert.NotContains(t, completions, "other.yaml") // doesn't match prefix
279 assert.NotContains(t, completions, "readme.md") // not a yaml file
280
281 // Should set NoFileComp
282 assert.NotEqual(t, cobra.ShellCompDirective(0), directive&cobra.ShellCompDirectiveNoFileComp,
283 "expected NoFileComp directive to be set")
284}
285
286func TestCompleteRunExec(t *testing.T) {
287 t.Parallel()

Callers

nothing calls this directly

Calls 2

completeAliasFunction · 0.85
writeFileFunction · 0.70

Tested by

no test coverage detected