Skip to content

Commit 5ce2bfb

Browse files
whyrusleepingKubuxu
authored andcommitted
add test to enforce helptext on commands
Add ProcessHelp call to Helptext test. License: MIT Signed-off-by: Jeromy <[email protected]> License: MIT Signed-off-by: Jakub Sztandera <[email protected]>
1 parent 06a6e2f commit 5ce2bfb

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

core/commands/helptext_test.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package commands
2+
3+
import (
4+
cmds "github.com/ipfs/go-ipfs/commands"
5+
"strings"
6+
"testing"
7+
)
8+
9+
func checkHelptextRecursive(t *testing.T, name []string, c *cmds.Command) {
10+
if c.Helptext.Tagline == "" {
11+
t.Errorf("%s has no tagline!", strings.Join(name, " "))
12+
}
13+
14+
if c.Helptext.LongDescription == "" {
15+
t.Errorf("%s has no long description!", strings.Join(name, " "))
16+
}
17+
18+
if c.Helptext.ShortDescription == "" {
19+
t.Errorf("%s has no short description!", strings.Join(name, " "))
20+
}
21+
22+
if c.Helptext.Synopsis == "" {
23+
t.Errorf("%s has no synopsis!", strings.Join(name, " "))
24+
}
25+
26+
for subname, sub := range c.Subcommands {
27+
checkHelptextRecursive(t, append(name, subname), sub)
28+
}
29+
}
30+
31+
func TestHelptexts(t *testing.T) {
32+
Root.ProcessHelp()
33+
checkHelptextRecursive(t, []string{"ipfs"}, Root)
34+
}

0 commit comments

Comments
 (0)