Adding test for Command.Hidden handling in help text

main
Dan Buch 8 years ago
parent 5c641d69b4
commit f397b1618c
No known key found for this signature in database
GPG Key ID: FAEF12936DD3E3EC

@ -2,6 +2,7 @@ package cli
import (
"bytes"
"strings"
"testing"
)
@ -110,3 +111,35 @@ func Test_Version_Custom_Flags(t *testing.T) {
t.Errorf("unexpected output: %s", output.String())
}
}
func TestShowAppHelp_HiddenCommand(t *testing.T) {
app := &App{
Commands: []Command{
Command{
Name: "frobbly",
Action: func(ctx *Context) error {
return nil
},
},
Command{
Name: "secretfrob",
Hidden: true,
Action: func(ctx *Context) error {
return nil
},
},
},
}
output := &bytes.Buffer{}
app.Writer = output
app.Run([]string{"app", "--help"})
if strings.Contains(output.String(), "secretfrob") {
t.Fatalf("expected output to exclude \"secretfrob\"; got: %q", output.String())
}
if !strings.Contains(output.String(), "frobbly") {
t.Fatalf("expected output to include \"frobbly\"; got: %q", output.String())
}
}

Loading…
Cancel
Save