2023-03-28 19:12:30 +00:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
2023-08-11 13:12:13 +00:00
|
|
|
// SPDX-License-Identifier: BUSL-1.1
|
2023-03-28 19:12:30 +00:00
|
|
|
|
2017-10-11 12:51:19 +00:00
|
|
|
package flags
|
2013-12-21 00:39:32 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"flag"
|
|
|
|
"reflect"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestAppendSliceValue_implements(t *testing.T) {
|
2017-10-17 14:07:48 +00:00
|
|
|
t.Parallel()
|
2013-12-21 00:39:32 +00:00
|
|
|
var raw interface{}
|
|
|
|
raw = new(AppendSliceValue)
|
|
|
|
if _, ok := raw.(flag.Value); !ok {
|
|
|
|
t.Fatalf("AppendSliceValue should be a Value")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestAppendSliceValueSet(t *testing.T) {
|
2017-10-17 14:07:48 +00:00
|
|
|
t.Parallel()
|
2013-12-21 00:39:32 +00:00
|
|
|
sv := new(AppendSliceValue)
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|