(t *testing.T)
| 996 | } |
| 997 | |
| 998 | func TestSetHelpCommand(t *testing.T) { |
| 999 | c := &Command{Use: "c", Run: emptyRun} |
| 1000 | c.AddCommand(&Command{Use: "empty", Run: emptyRun}) |
| 1001 | |
| 1002 | expected := "WORKS" |
| 1003 | c.SetHelpCommand(&Command{ |
| 1004 | Use: "help [command]", |
| 1005 | Short: "Help about any command", |
| 1006 | Long: `Help provides help for any command in the application. |
| 1007 | Simply type ` + c.Name() + ` help [path to command] for full details.`, |
| 1008 | Run: func(c *Command, _ []string) { c.Print(expected) }, |
| 1009 | }) |
| 1010 | |
| 1011 | got, err := executeCommand(c, "help") |
| 1012 | if err != nil { |
| 1013 | t.Errorf("Unexpected error: %v", err) |
| 1014 | } |
| 1015 | |
| 1016 | if got != expected { |
| 1017 | t.Errorf("Expected to contain %q, got %q", expected, got) |
| 1018 | } |
| 1019 | } |
| 1020 | |
| 1021 | func TestSetHelpTemplate(t *testing.T) { |
| 1022 | rootCmd := &Command{Use: "root", Run: emptyRun} |
nothing calls this directly
no test coverage detected