(t *testing.T)
| 410 | } |
| 411 | |
| 412 | func TestChildTakesNoArgs(t *testing.T) { |
| 413 | rootCmd := &Command{Use: "root", Run: emptyRun} |
| 414 | childCmd := &Command{Use: "child", Args: NoArgs, Run: emptyRun} |
| 415 | rootCmd.AddCommand(childCmd) |
| 416 | |
| 417 | _, err := executeCommand(rootCmd, "child", "illegal", "args") |
| 418 | if err == nil { |
| 419 | t.Fatal("Expected an error") |
| 420 | } |
| 421 | |
| 422 | got := err.Error() |
| 423 | expected := `unknown command "illegal" for "root child"` |
| 424 | if !strings.Contains(got, expected) { |
| 425 | t.Errorf("expected %q, got %q", expected, got) |
| 426 | } |
| 427 | } |
| 428 | |
| 429 | func TestChildTakesArgs(t *testing.T) { |
| 430 | rootCmd := &Command{Use: "root", Run: emptyRun} |
nothing calls this directly
no test coverage detected