Move checkHelptextRecursive forward a bit
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
Łukasz Magiera committed
Jan 3, 2019 at 22:47 UTC
1f479aa54c69c2a94d3fb1b3bc0e7be3bf490b6a
2 files changed
+37
-16
core/commands/helptext_test.go
+34
-16
@@ -8,21 +8,40 @@ import (
8
)
9
10
func checkHelptextRecursive(t *testing.T, name []string, c *cmds.Command) {
11
- if c.Helptext.Tagline == "" {
12
- t.Errorf("%s has no tagline!", strings.Join(name, " "))
13
- }
14
-
15
- if c.Helptext.LongDescription == "" {
16
- t.Errorf("%s has no long description!", strings.Join(name, " "))
17
- }
18
-
19
- if c.Helptext.ShortDescription == "" {
20
- t.Errorf("%s has no short description!", strings.Join(name, " "))
21
- }
22
-
23
- if c.Helptext.Synopsis == "" {
24
- t.Errorf("%s has no synopsis!", strings.Join(name, " "))
25
- }
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)
@@ -30,7 +49,6 @@ func checkHelptextRecursive(t *testing.T, name []string, c *cmds.Command) {
49
}
50
51
func TestHelptexts(t *testing.T) {
33
- t.Skip("sill isn't 100%")
52
Root.ProcessHelp()
53
checkHelptextRecursive(t, []string{"ipfs"}, Root)
54
}
core/commands/urlstore.go
+3
@@ -20,6 +20,9 @@ import (
20
)
21
22
var urlStoreCmd = &cmds.Command{
23
+ Helptext: cmdkit.HelpText{
24
+ Tagline: "Interact with urlstore.",
25
+ },
26
Subcommands: map[string]*cmds.Command{
27
"add": urlAdd,
28
},