open-vault/meta/meta_test.go

42 lines
769 B
Go
Raw Normal View History

2016-04-01 17:16:05 +00:00
package meta
2015-03-04 07:49:37 +00:00
import (
"flag"
"reflect"
"sort"
"testing"
)
func TestFlagSet(t *testing.T) {
cases := []struct {
Flags FlagSetFlags
Expected []string
}{
{
FlagSetNone,
[]string{},
},
{
FlagSetServer,
2017-10-23 20:42:56 +00:00
[]string{"address", "ca-cert", "ca-path", "client-cert", "client-key", "insecure", "mfa", "policy-override", "tls-skip-verify", "wrap-ttl"},
2015-03-04 07:49:37 +00:00
},
}
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)
}
}
}