Skip to content

Commit

Permalink
add test to enforce helptext on commands
Browse files Browse the repository at this point in the history
Add ProcessHelp call to Helptext test.

License: MIT
Signed-off-by: Jeromy <why@ipfs.io>

License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
  • Loading branch information
whyrusleeping authored and Kubuxu committed Sep 28, 2016
1 parent 06a6e2f commit 5ce2bfb
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions core/commands/helptext_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package commands

import (
cmds "github.com/ipfs/go-ipfs/commands"
"strings"
"testing"
)

func checkHelptextRecursive(t *testing.T, name []string, c *cmds.Command) {
if c.Helptext.Tagline == "" {
t.Errorf("%s has no tagline!", strings.Join(name, " "))
}

if c.Helptext.LongDescription == "" {
t.Errorf("%s has no long description!", strings.Join(name, " "))
}

if c.Helptext.ShortDescription == "" {
t.Errorf("%s has no short description!", strings.Join(name, " "))
}

if c.Helptext.Synopsis == "" {
t.Errorf("%s has no synopsis!", strings.Join(name, " "))
}

for subname, sub := range c.Subcommands {
checkHelptextRecursive(t, append(name, subname), sub)
}
}

func TestHelptexts(t *testing.T) {
Root.ProcessHelp()
checkHelptextRecursive(t, []string{"ipfs"}, Root)
}

0 comments on commit 5ce2bfb

Please sign in to comment.