From 3e874b31b7b9420712b2c6ef364e7a76a5e1e695 Mon Sep 17 00:00:00 2001 From: spf13 Date: Fri, 13 Jun 2014 20:45:55 -0400 Subject: [PATCH] Test confirming fixed #11 --- cobra_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/cobra_test.go b/cobra_test.go index 44e6afe..b479fe1 100644 --- a/cobra_test.go +++ b/cobra_test.go @@ -335,6 +335,24 @@ func TestChildCommandFlags(t *testing.T) { if !strings.Contains(buf.String(), "intone=123") { t.Errorf("Wrong error message displayed, \n %s", buf.String()) } + + // Testing flag with invalid input + buf.Reset() + c = initialize() + c.SetOutput(buf) + cmdEcho.AddCommand(cmdTimes) + c.AddCommand(cmdPrint, cmdEcho) + c.SetArgs(strings.Split("echo -i10E", " ")) + err = c.Execute() + + if err == nil { + t.Errorf("invalid input should generate error") + } + + if !strings.Contains(buf.String(), "invalid argument \"10E\" for -i10E") { + t.Errorf("Wrong error message displayed, \n %s", buf.String()) + } + } func TestTrailingCommandFlags(t *testing.T) {