mirror of
https://github.com/spf13/cobra
synced 2024-11-24 14:47:12 +00:00
Added test for (fixed) bug in upstream library pflag
This commit is contained in:
parent
7216b06e83
commit
2f19d3c266
1 changed files with 14 additions and 0 deletions
|
@ -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) {
|
func TestPersistentFlags(t *testing.T) {
|
||||||
c := initialize()
|
c := initialize()
|
||||||
cmdEcho.AddCommand(cmdTimes)
|
cmdEcho.AddCommand(cmdTimes)
|
||||||
|
|
Loading…
Reference in a new issue