From 2f19d3c266ac08b9abe0b4ba9c7e90a188b60a4f Mon Sep 17 00:00:00 2001 From: spf13 Date: Tue, 5 Nov 2013 19:50:47 -0500 Subject: [PATCH] Added test for (fixed) bug in upstream library pflag --- cobra_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/cobra_test.go b/cobra_test.go index dc80f297..96fffb48 100644 --- a/cobra_test.go +++ b/cobra_test.go @@ -257,6 +257,20 @@ func TestChildCommandFlags(t *testing.T) { } } +func TestTrailingCommandFlags(t *testing.T) { + buf := new(bytes.Buffer) + c := initialize() + c.SetOutput(buf) + cmdEcho.AddCommand(cmdTimes) + c.AddCommand(cmdPrint, cmdEcho) + c.SetArgs(strings.Split("echo two -x", " ")) + e3 := c.Execute() + + if e3 == nil { + t.Errorf("invalid flag should generate error") + } +} + func TestPersistentFlags(t *testing.T) { c := initialize() cmdEcho.AddCommand(cmdTimes)