mirror of
https://github.com/spf13/cobra
synced 2024-11-24 14:47:12 +00:00
Test confirming fixed #11
This commit is contained in:
parent
1a6c5d1d21
commit
3e874b31b7
1 changed files with 18 additions and 0 deletions
|
@ -335,6 +335,24 @@ func TestChildCommandFlags(t *testing.T) {
|
||||||
if !strings.Contains(buf.String(), "intone=123") {
|
if !strings.Contains(buf.String(), "intone=123") {
|
||||||
t.Errorf("Wrong error message displayed, \n %s", buf.String())
|
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) {
|
func TestTrailingCommandFlags(t *testing.T) {
|
||||||
|
|
Loading…
Reference in a new issue