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

Function TestValidArgsFuncInBashScript

completions_test.go:1544–1558  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1542}
1543
1544func TestValidArgsFuncInBashScript(t *testing.T) {
1545 rootCmd := &Command{Use: "root", Args: NoArgs, Run: emptyRun}
1546 child := &Command{
1547 Use: "child",
1548 ValidArgsFunction: validArgsFunc,
1549 Run: emptyRun,
1550 }
1551 rootCmd.AddCommand(child)
1552
1553 buf := new(bytes.Buffer)
1554 assertNoErr(t, rootCmd.GenBashCompletion(buf))
1555 output := buf.String()
1556
1557 check(t, output, "has_completion_function=1")
1558}
1559
1560func TestNoValidArgsFuncInBashScript(t *testing.T) {
1561 rootCmd := &Command{Use: "root", Args: NoArgs, Run: emptyRun}

Callers

nothing calls this directly

Calls 5

AddCommandMethod · 0.95
GenBashCompletionMethod · 0.95
checkFunction · 0.85
StringMethod · 0.80
assertNoErrFunction · 0.70

Tested by

no test coverage detected