mirror of
https://github.com/ipfs/kubo.git
synced 2025-10-19 12:42:23 +08:00
Add logic for copying ShortDes to LongDesc if it is not present
This is the best place for inserting it that I found. Test in #2648 should be modified to run `Root.ProcessHelp()`. License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
This commit is contained in:
@ -155,3 +155,42 @@ func TestResolving(t *testing.T) {
|
||||
t.Error("Returned command path is different than expected", cmds)
|
||||
}
|
||||
}
|
||||
|
||||
func TestWalking(t *testing.T) {
|
||||
cmdA := &Command{
|
||||
Subcommands: map[string]*Command{
|
||||
"b": &Command{},
|
||||
"B": &Command{},
|
||||
},
|
||||
}
|
||||
i := 0
|
||||
cmdA.Walk(func(c *Command) {
|
||||
i = i + 1
|
||||
})
|
||||
if i != 3 {
|
||||
t.Error("Command tree walk didn't work, expected 3 got:", i)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHelpProcessing(t *testing.T) {
|
||||
cmdB := &Command{
|
||||
Helptext: HelpText{
|
||||
ShortDescription: "This is other short",
|
||||
},
|
||||
}
|
||||
cmdA := &Command{
|
||||
Helptext: HelpText{
|
||||
ShortDescription: "This is short",
|
||||
},
|
||||
Subcommands: map[string]*Command{
|
||||
"a": cmdB,
|
||||
},
|
||||
}
|
||||
cmdA.ProcessHelp()
|
||||
if len(cmdA.Helptext.LongDescription) == 0 {
|
||||
t.Error("LongDescription was not set on basis of ShortDescription")
|
||||
}
|
||||
if len(cmdB.Helptext.LongDescription) == 0 {
|
||||
t.Error("LongDescription was not set on basis of ShortDescription")
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user