Skip to content

Commit

Permalink
adjust test around command description
Browse files Browse the repository at this point in the history
When no direct action is defined in the command, the command only
displays a help.
In this case, `cli.SubcommandHelpTemplate` is used for default template
and the `.Description` need not be defined, so there is no problem if
either `.Description` or `.Usage` is defined.
  • Loading branch information
Songmu committed Jan 15, 2019
1 parent f5037c6 commit 2eacd45
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"strings"
"testing"

"gopkg.in/urfave/cli.v1"
cli "gopkg.in/urfave/cli.v1"
)

func TestCommands_requirements(t *testing.T) {
Expand All @@ -31,7 +31,12 @@ func TestCommands_requirements(t *testing.T) {
}
}
for _, sc := range subcs {
if sc.Description == "" {
if sc.Action == nil {
if sc.Description == "" && sc.Usage == "" {
t.Errorf("%s: Neither .Description nor .Usage should be empty", sc.Name)

}
} else if sc.Description == "" {
t.Errorf("%s: cli.Command.Description should not be empty", sc.Name)
}
}
Expand Down

0 comments on commit 2eacd45

Please sign in to comment.