@cryptotaxi247 / kubo / commits / e7e22597c

add test to enforce helptext on commands

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

Jeromy committed May 10, 2016 at 09:01 UTC e7e22597ce2c9a17b850a938f1801895df05a6e4
1 file changed +33
core/commands/helptext_test.go new
+33
@@ -0,0 +1,33 @@
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 + checkHelptextRecursive(t, []string{"ipfs"}, Root)
33 +}