2017-04-06 17:44:53 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2017-05-16 18:49:18 +00:00
|
|
|
"io/ioutil"
|
2017-04-06 17:44:53 +00:00
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
// TestFlags checks for double defined flags, the commands will panic on
|
|
|
|
// ParseFlags() when a shorthand flag is defined twice.
|
|
|
|
func TestFlags(t *testing.T) {
|
|
|
|
for _, cmd := range cmdRoot.Commands() {
|
|
|
|
t.Run(cmd.Name(), func(t *testing.T) {
|
2017-05-16 18:49:18 +00:00
|
|
|
cmd.Flags().SetOutput(ioutil.Discard)
|
2017-04-06 17:44:53 +00:00
|
|
|
err := cmd.ParseFlags([]string{"--help"})
|
|
|
|
if err.Error() == "pflag: help requested" {
|
|
|
|
err = nil
|
|
|
|
}
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|