MCPcopy
hub / github.com/spf13/cobra / TestBashCompletionTraverseChildren

Function TestBashCompletionTraverseChildren

bash_completions_test.go:261–277  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

259}
260
261func TestBashCompletionTraverseChildren(t *testing.T) {
262 c := &Command{Use: "c", Run: emptyRun, TraverseChildren: true}
263
264 c.Flags().StringP("string-flag", "s", "", "string flag")
265 c.Flags().BoolP("bool-flag", "b", false, "bool flag")
266
267 buf := new(bytes.Buffer)
268 assertNoErr(t, c.GenBashCompletion(buf))
269 output := buf.String()
270
271 // check that local nonpersistent flag are not set since we have TraverseChildren set to true
272 checkOmit(t, output, `local_nonpersistent_flags+=("--string-flag")`)
273 checkOmit(t, output, `local_nonpersistent_flags+=("--string-flag=")`)
274 checkOmit(t, output, `local_nonpersistent_flags+=("-s")`)
275 checkOmit(t, output, `local_nonpersistent_flags+=("--bool-flag")`)
276 checkOmit(t, output, `local_nonpersistent_flags+=("-b")`)
277}
278
279func TestBashCompletionNoActiveHelp(t *testing.T) {
280 c := &Command{Use: "c", Run: emptyRun}

Callers

nothing calls this directly

Calls 5

FlagsMethod · 0.95
GenBashCompletionMethod · 0.95
checkOmitFunction · 0.85
StringMethod · 0.80
assertNoErrFunction · 0.70

Tested by

no test coverage detected