github.com/rposudnevskiy/consul@v1.4.5/command/flags/flag_slice_value_test.go (about)

     1  package flags
     2  
     3  import (
     4  	"flag"
     5  	"reflect"
     6  	"testing"
     7  )
     8  
     9  func TestAppendSliceValue_implements(t *testing.T) {
    10  	t.Parallel()
    11  	var raw interface{}
    12  	raw = new(AppendSliceValue)
    13  	if _, ok := raw.(flag.Value); !ok {
    14  		t.Fatalf("AppendSliceValue should be a Value")
    15  	}
    16  }
    17  
    18  func TestAppendSliceValueSet(t *testing.T) {
    19  	t.Parallel()
    20  	sv := new(AppendSliceValue)
    21  	err := sv.Set("foo")
    22  	if err != nil {
    23  		t.Fatalf("err: %s", err)
    24  	}
    25  
    26  	err = sv.Set("bar")
    27  	if err != nil {
    28  		t.Fatalf("err: %s", err)
    29  	}
    30  
    31  	expected := []string{"foo", "bar"}
    32  	if !reflect.DeepEqual([]string(*sv), expected) {
    33  		t.Fatalf("Bad: %#v", sv)
    34  	}
    35  }