open-nomad/command/meta_test.go

54 lines
834 B
Go
Raw Normal View History

2015-06-01 13:25:51 +00:00
package command
import (
"flag"
"reflect"
"sort"
"testing"
)
func TestMeta_FlagSet(t *testing.T) {
2017-07-21 04:24:21 +00:00
t.Parallel()
2015-06-01 13:25:51 +00:00
cases := []struct {
Flags FlagSetFlags
Expected []string
}{
{
FlagSetNone,
[]string{},
},
{
FlagSetClient,
2016-10-26 21:08:46 +00:00
[]string{
"address",
"no-color",
"region",
2017-09-07 23:56:15 +00:00
"namespace",
2016-10-26 21:08:46 +00:00
"ca-cert",
"ca-path",
"client-cert",
"client-key",
"insecure",
"tls-skip-verify",
},
2015-06-01 13:25:51 +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)
}
}
}