helptext_test.go
1 package commands 2 3 import ( 4 "strings" 5 "testing" 6 7 cmds "github.com/ipfs/go-ipfs-cmds" 8 ) 9 10 func checkHelptextRecursive(t *testing.T, name []string, c *cmds.Command) { 11 c.ProcessHelp() 12 13 t.Run(strings.Join(name, "_"), func(t *testing.T) { 14 if c.External { 15 t.Skip("external") 16 } 17 18 t.Run("tagline", func(t *testing.T) { 19 if c.Helptext.Tagline == "" { 20 t.Error("no Tagline!") 21 } 22 }) 23 24 t.Run("longDescription", func(t *testing.T) { 25 t.Skip("not everywhere yet") 26 if c.Helptext.LongDescription == "" { 27 t.Error("no LongDescription!") 28 } 29 }) 30 31 t.Run("shortDescription", func(t *testing.T) { 32 t.Skip("not everywhere yet") 33 if c.Helptext.ShortDescription == "" { 34 t.Error("no ShortDescription!") 35 } 36 }) 37 38 t.Run("synopsis", func(t *testing.T) { 39 t.Skip("autogenerated in go-ipfs-cmds") 40 if c.Helptext.Synopsis == "" { 41 t.Error("no Synopsis!") 42 } 43 }) 44 }) 45 46 for subname, sub := range c.Subcommands { 47 checkHelptextRecursive(t, append(name, subname), sub) 48 } 49 } 50 51 func TestHelptexts(t *testing.T) { 52 Root.ProcessHelp() 53 checkHelptextRecursive(t, []string{"ipfs"}, Root) 54 }