Indent multi-line messages/errors.

This commit is contained in:
Alec Thomas
2018-06-20 12:44:18 +10:00
parent 9a68d32e72
commit 3a2f3eebdd
4 changed files with 25 additions and 5 deletions
+10
View File
@@ -1,6 +1,7 @@
package kong
import (
"bytes"
"strings"
"testing"
@@ -10,6 +11,7 @@ import (
func mustNew(t *testing.T, cli interface{}, options ...Option) *Kong {
t.Helper()
options = append([]Option{
Name("test"),
Exit(func(int) {
t.Helper()
t.Fatalf("unexpected exit()")
@@ -444,3 +446,11 @@ func TestSliceWithDisabledSeparator(t *testing.T) {
require.NoError(t, err)
require.Equal(t, []string{"a,b", "b,c"}, cli.Flag)
}
func TestMultilineMessage(t *testing.T) {
w := &bytes.Buffer{}
var cli struct{}
p := mustNew(t, &cli, Writers(w, w))
p.Printf("hello\nworld")
require.Equal(t, "test: hello\n world\n", w.String())
}