Adding test for Command.Hidden handling in help text
This commit is contained in:
parent
5c641d69b4
commit
f397b1618c
33
help_test.go
33
help_test.go
@ -2,6 +2,7 @@ package cli
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -110,3 +111,35 @@ func Test_Version_Custom_Flags(t *testing.T) {
|
|||||||
t.Errorf("unexpected output: %s", output.String())
|
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…
Reference in New Issue
Block a user