open-vault/command/meta_test.go

42 lines
686 B
Go
Raw Normal View History

2015-03-04 07:49:37 +00:00
package command
import (
"flag"
"reflect"
"sort"
"testing"
)
func TestFlagSet(t *testing.T) {
cases := []struct {
Flags FlagSetFlags
Expected []string
}{
{
FlagSetNone,
[]string{},
},
{
FlagSetServer,
[]string{"address", "ca-cert", "ca-path", "insecure"},
},
}
for i, tc := range cases {
var m Meta
fs := m.FlagSet("foo", tc.Flags)
actual := make([]string, 0, 0)
fs.VisitAll(func(f *flag.Flag) {
actual = append(actual, f.Name)
})
sort.Strings(actual)
sort.Strings(tc.Expected)
if !reflect.DeepEqual(actual, tc.Expected) {
t.Fatalf("%d: flags: %#v\n\nExpected: %#v\nGot: %#v",
i, tc.Flags, tc.Expected, actual)
}
}
}