Make test case more robust
This commit is contained in:
parent
d89bc4a6e2
commit
96e41a628a
1
help.go
1
help.go
@ -297,7 +297,6 @@ func printHelpCustom(out io.Writer, templ string, data interface{}, customFuncs
|
||||
funcMap := template.FuncMap{
|
||||
"join": strings.Join,
|
||||
"subtract": subtract,
|
||||
"add": add,
|
||||
"indent": indent,
|
||||
"nindent": nindent,
|
||||
"trim": strings.TrimSpace,
|
||||
|
15
help_test.go
15
help_test.go
@ -907,6 +907,11 @@ App UsageText`,
|
||||
Aliases: []string{"frb1", "frbb2", "frl2"},
|
||||
Usage: "this is a long help output for the run command, long usage \noutput, long usage output, long usage output, long usage output\noutput, long usage output, long usage output",
|
||||
},
|
||||
{
|
||||
Name: "grobbly",
|
||||
Aliases: []string{"grb1", "grbb2"},
|
||||
Usage: "this is another long help output for the run command, long usage \noutput, long usage output",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@ -915,10 +920,12 @@ App UsageText`,
|
||||
|
||||
_ = app.Run([]string{"foo"})
|
||||
|
||||
expected := `frobbly, frb1, frbb2, frl2 this is a long help output for the run command, long usage
|
||||
output, long usage output, long usage output, long usage output
|
||||
output, long usage output, long usage output`
|
||||
|
||||
expected := "COMMANDS:\n" +
|
||||
" frobbly, frb1, frbb2, frl2 this is a long help output for the run command, long usage \n" +
|
||||
" output, long usage output, long usage output, long usage output\n" +
|
||||
" output, long usage output, long usage output\n" +
|
||||
" grobbly, grb1, grbb2 this is another long help output for the run command, long usage \n" +
|
||||
" output, long usage output"
|
||||
if !strings.Contains(output.String(), expected) {
|
||||
t.Errorf("expected output to include usage text; got: %q", output.String())
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ AUTHOR{{with $length := len .Authors}}{{if ne 1 $length}}S{{end}}{{end}}:
|
||||
COMMANDS:{{range .VisibleCategories}}{{if .Name}}
|
||||
{{.Name}}:{{range .VisibleCommands}}
|
||||
{{join .Names ", "}}{{"\t"}}{{.Usage}}{{end}}{{else}}{{ $cv := offsetCommands .VisibleCommands 5}}{{range .VisibleCommands}}
|
||||
{{$s := join .Names ", "}}{{$s}}{{ $sp := subtract $cv (add (len $s) 3) }}{{ indent $sp ""}}{{wrap .Usage $cv}}{{end}}{{end}}{{end}}{{end}}{{if .VisibleFlagCategories}}
|
||||
{{$s := join .Names ", "}}{{$s}}{{ $sp := subtract $cv (offset $s 3) }}{{ indent $sp ""}}{{wrap .Usage $cv}}{{end}}{{end}}{{end}}{{end}}{{if .VisibleFlagCategories}}
|
||||
|
||||
GLOBAL OPTIONS:{{range .VisibleFlagCategories}}
|
||||
{{if .Name}}{{.Name}}
|
||||
@ -77,7 +77,7 @@ DESCRIPTION:
|
||||
COMMANDS:{{range .VisibleCategories}}{{if .Name}}
|
||||
{{.Name}}:{{range .VisibleCommands}}
|
||||
{{join .Names ", "}}{{"\t"}}{{.Usage}}{{end}}{{else}}{{ $cv := offsetCommands .VisibleCommands 5}}{{range .VisibleCommands}}
|
||||
{{$s := join .Names ", "}}{{$s}}{{ $sp := subtract $cv (add (len $s) 3) }}{{ indent $sp ""}}{{wrap .Usage $cv}}{{end}}{{end}}{{end}}{{if .VisibleFlags}}
|
||||
{{$s := join .Names ", "}}{{$s}}{{ $sp := subtract $cv (offset $s 3) }}{{ indent $sp ""}}{{wrap .Usage $cv}}{{end}}{{end}}{{end}}{{if .VisibleFlags}}
|
||||
|
||||
OPTIONS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
|
Loading…
Reference in New Issue
Block a user