Add better persistent flags testing

This commit is contained in:
spf13 2013-09-10 18:26:46 -04:00
parent 061ba30a84
commit c5eb49e3f5
1 changed files with 17 additions and 0 deletions

View File

@ -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)
}
}