From e5cad57101736f780a373672989787b0606d9b76 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Tue, 10 May 2016 09:01:12 -0700 Subject: [PATCH] add test to enforce helptext on commands License: MIT Signed-off-by: Jeromy --- core/commands/helptext_test.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 core/commands/helptext_test.go diff --git a/core/commands/helptext_test.go b/core/commands/helptext_test.go new file mode 100644 index 000000000000..29da2a4a5cdf --- /dev/null +++ b/core/commands/helptext_test.go @@ -0,0 +1,33 @@ +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) { + checkHelptextRecursive(t, []string{"ipfs"}, Root) +}