mirror of
https://github.com/spf13/cobra
synced 2024-11-05 05:17:12 +00:00
Add better persistent flags testing
This commit is contained in:
parent
061ba30a84
commit
c5eb49e3f5
1 changed files with 17 additions and 0 deletions
|
@ -223,4 +223,21 @@ func TestPersistentFlags(t *testing.T) {
|
|||
t.Errorf("string flag didn't get correct value, had %v", flags1)
|
||||
}
|
||||
|
||||
c = initialize()
|
||||
cmdEcho.AddCommand(cmdTimes)
|
||||
c.AddCommand(cmdPrint, cmdEcho)
|
||||
c.SetArgs(strings.Split("echo times -s again -c test here", " "))
|
||||
c.Execute()
|
||||
|
||||
if strings.Join(tt, " ") != "test here" {
|
||||
t.Errorf("flags didn't leave proper args remaining..%s given", tt)
|
||||
}
|
||||
|
||||
if flags1 != "again" {
|
||||
t.Errorf("string flag didn't get correct value, had %v", flags1)
|
||||
}
|
||||
|
||||
if flagb2 != true {
|
||||
t.Errorf("local flag not parsed correctly. Expected false, had %v", flagb2)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue