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

Function TestRootTakesArgs

args_test.go:401–410  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

399}
400
401func TestRootTakesArgs(t *testing.T) {
402 rootCmd := &Command{Use: "root", Args: ArbitraryArgs, Run: emptyRun}
403 childCmd := &Command{Use: "child", Run: emptyRun}
404 rootCmd.AddCommand(childCmd)
405
406 _, err := executeCommand(rootCmd, "legal", "args")
407 if err != nil {
408 t.Errorf("Unexpected error: %v", err)
409 }
410}
411
412func TestChildTakesNoArgs(t *testing.T) {
413 rootCmd := &Command{Use: "root", Run: emptyRun}

Callers

nothing calls this directly

Calls 2

AddCommandMethod · 0.95
executeCommandFunction · 0.85

Tested by

no test coverage detected