mirror of
https://github.com/restic/restic.git
synced 2025-05-17 06:08:35 +00:00
27 lines
505 B
Go
27 lines
505 B
Go
![]() |
package main
|
||
|
|
||
|
import (
|
||
|
"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) {
|
||
|
err := cmd.ParseFlags([]string{"--help"})
|
||
|
if err.Error() == "pflag: help requested" {
|
||
|
err = nil
|
||
|
}
|
||
|
|
||
|
if err != nil {
|
||
|
t.Fatal(err)
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
}
|