open-nomad/helper/flag-helpers/flag_test.go

34 lines
558 B
Go
Raw Normal View History

2016-10-11 01:04:39 +00:00
package flaghelper
2015-08-16 21:34:38 +00:00
import (
"flag"
"reflect"
"testing"
)
2015-08-23 23:57:54 +00:00
func TestStringFlag_implements(t *testing.T) {
2015-08-16 21:34:38 +00:00
var raw interface{}
2015-08-23 23:57:54 +00:00
raw = new(StringFlag)
2015-08-16 21:34:38 +00:00
if _, ok := raw.(flag.Value); !ok {
2015-08-23 23:57:54 +00:00
t.Fatalf("StringFlag should be a Value")
2015-08-16 21:34:38 +00:00
}
}
2015-08-23 23:57:54 +00:00
func TestStringFlagSet(t *testing.T) {
sv := new(StringFlag)
2015-08-16 21:34:38 +00:00
err := sv.Set("foo")
if err != nil {
t.Fatalf("err: %s", err)
}
err = sv.Set("bar")
if err != nil {
t.Fatalf("err: %s", err)
}
expected := []string{"foo", "bar"}
if !reflect.DeepEqual([]string(*sv), expected) {
t.Fatalf("Bad: %#v", sv)
}
}