2
2
mirror of https://github.com/octoleo/restic.git synced 2024-06-05 10:30:49 +00:00
restic/src/cmds/restic/flags_test.go
2017-05-16 20:49:18 +02:00

29 lines
559 B
Go

package main
import (
"io/ioutil"
"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) {
type FlagParser interface {
ParseFlags([]string) error
}
for _, cmd := range cmdRoot.Commands() {
t.Run(cmd.Name(), func(t *testing.T) {
cmd.Flags().SetOutput(ioutil.Discard)
err := cmd.ParseFlags([]string{"--help"})
if err.Error() == "pflag: help requested" {
err = nil
}
if err != nil {
t.Fatal(err)
}
})
}
}