helptext_test.go 1.08 KB
Newer Older
1 2 3 4 5
package commands

import (
	"strings"
	"testing"
6

Jakub Sztandera's avatar
Jakub Sztandera committed
7
	cmds "github.com/ipfs/go-ipfs-cmds"
8 9 10
)

func checkHelptextRecursive(t *testing.T, name []string, c *cmds.Command) {
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
	c.ProcessHelp()

	t.Run(strings.Join(name, "_"), func(t *testing.T) {
		if c.External {
			t.Skip("external")
		}

		t.Run("tagline", func(t *testing.T) {
			if c.Helptext.Tagline == "" {
				t.Error("no Tagline!")
			}
		})

		t.Run("longDescription", func(t *testing.T) {
			t.Skip("not everywhere yet")
			if c.Helptext.LongDescription == "" {
				t.Error("no LongDescription!")
			}
		})

		t.Run("shortDescription", func(t *testing.T) {
			t.Skip("not everywhere yet")
			if c.Helptext.ShortDescription == "" {
				t.Error("no ShortDescription!")
			}
		})

		t.Run("synopsis", func(t *testing.T) {
			t.Skip("autogenerated in go-ipfs-cmds")
			if c.Helptext.Synopsis == "" {
				t.Error("no Synopsis!")
			}
		})
	})
45 46 47 48 49 50 51

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

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