mirror of
https://github.com/spf13/cobra
synced 2025-04-27 09:07:19 +00:00
Fix unnecessary Sprintf.
This commit is contained in:
parent
5897ead246
commit
b81f68ad85
1 changed files with 8 additions and 6 deletions
|
@ -1399,6 +1399,8 @@ func TestCustomSuggestions(t *testing.T) {
|
||||||
rootCmd.AddCommand(timesCmd)
|
rootCmd.AddCommand(timesCmd)
|
||||||
|
|
||||||
var expected, output string
|
var expected, output string
|
||||||
|
suggestion := "times"
|
||||||
|
typo := "time"
|
||||||
|
|
||||||
expected = ""
|
expected = ""
|
||||||
output, _ = executeCommand(rootCmd, "times")
|
output, _ = executeCommand(rootCmd, "times")
|
||||||
|
@ -1406,16 +1408,16 @@ func TestCustomSuggestions(t *testing.T) {
|
||||||
t.Errorf("\nExpected:\n %q\nGot:\n %q", expected, output)
|
t.Errorf("\nExpected:\n %q\nGot:\n %q", expected, output)
|
||||||
}
|
}
|
||||||
|
|
||||||
expected = fmt.Sprintf("Error: unknown command \"%s\" for \"root\"\n\nDid you mean this?\n\t%s\n\nRun 'root --help' for usage.\n", "time", "times")
|
expected = fmt.Sprintf("Error: unknown command \"%s\" for \"root\"\n\nDid you mean this?\n\t%s\n\nRun 'root --help' for usage.\n", typo, suggestion)
|
||||||
output, _ = executeCommand(rootCmd, "time")
|
output, _ = executeCommand(rootCmd, typo)
|
||||||
if output != expected {
|
if output != expected {
|
||||||
t.Errorf("\nExpected:\n %q\nGot:\n %q", expected, output)
|
t.Errorf("\nExpected:\n %q\nGot:\n %q", expected, output)
|
||||||
}
|
}
|
||||||
|
|
||||||
rootCmd.DisableSuggestions = true
|
rootCmd.DisableSuggestions = true
|
||||||
|
|
||||||
expected = fmt.Sprintf("Error: unknown command \"%s\" for \"root\"\nRun 'root --help' for usage.\n", "time")
|
expected = fmt.Sprintf("Error: unknown command \"%s\" for \"root\"\nRun 'root --help' for usage.\n", typo)
|
||||||
output, _ = executeCommand(rootCmd, "time")
|
output, _ = executeCommand(rootCmd, typo)
|
||||||
if output != expected {
|
if output != expected {
|
||||||
t.Errorf("\nExpected:\n %q\nGot:\n %q", expected, output)
|
t.Errorf("\nExpected:\n %q\nGot:\n %q", expected, output)
|
||||||
}
|
}
|
||||||
|
@ -1425,8 +1427,8 @@ func TestCustomSuggestions(t *testing.T) {
|
||||||
return fmt.Sprintf("\nSuggestions:\n\t%s\n", strings.Join(suggestions, "\n"))
|
return fmt.Sprintf("\nSuggestions:\n\t%s\n", strings.Join(suggestions, "\n"))
|
||||||
})
|
})
|
||||||
|
|
||||||
expected = fmt.Sprintf("Error: unknown command \"time\" for \"root\"\nSuggestions:\n\ttimes\n\nRun 'root --help' for usage.\n")
|
expected = fmt.Sprintf("Error: unknown command \"%s\" for \"root\"\nSuggestions:\n\t%s\n\nRun 'root --help' for usage.\n", typo, suggestion)
|
||||||
output, _ = executeCommand(rootCmd, "time")
|
output, _ = executeCommand(rootCmd, typo)
|
||||||
if output != expected {
|
if output != expected {
|
||||||
t.Errorf("\nExpected:\n %q\nGot:\n %q", expected, output)
|
t.Errorf("\nExpected:\n %q\nGot:\n %q", expected, output)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue