diff options
Diffstat (limited to 'multi_string_flag_test.go')
-rw-r--r-- | multi_string_flag_test.go | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/multi_string_flag_test.go b/multi_string_flag_test.go index c09f7225..9c9c7d48 100644 --- a/multi_string_flag_test.go +++ b/multi_string_flag_test.go @@ -1,6 +1,7 @@ package main import ( + "strings" "testing" "github.com/stretchr/testify/require" @@ -15,7 +16,7 @@ func TestMultiStringFlagAppendsOnSet(t *testing.T) { require.EqualError(t, iface.Set(""), "value cannot be empty") - require.Equal(t, MultiStringFlag{"foo", "bar"}, concrete) + require.Equal(t, MultiStringFlag{value: []string{"foo", "bar"}}, concrete) } func TestMultiStringFlag_Split(t *testing.T) { @@ -31,19 +32,30 @@ func TestMultiStringFlag_Split(t *testing.T) { }, { name: "one_value", - s: &MultiStringFlag{"value1"}, // -flag "value1" + s: &MultiStringFlag{value: []string{"value1"}}, // -flag "value1" wantResult: []string{"value1"}, }, { name: "multiple_values", - s: &MultiStringFlag{"value1", "", "value3"}, // -flag "value1,,value3" + s: &MultiStringFlag{value: []string{"value1", "", "value3"}}, // -flag "value1,,value3" wantResult: []string{"value1", "", "value3"}, }, + { + name: "multiple_values_in_one_string", + s: &MultiStringFlag{value: []string{"value1,value2"}}, // -flag "value1,value2" + wantResult: []string{"value1", "value2"}, + }, + { + name: "different_separator", + s: &MultiStringFlag{value: []string{"value1", "value2"}, separator: ";"}, // -flag "value1;value2" + wantResult: []string{"value1", "value2"}, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { gotResult := tt.s.Split() require.ElementsMatch(t, tt.wantResult, gotResult) + require.Equal(t, strings.Join(gotResult, tt.s.separator), strings.Join(tt.wantResult, tt.s.separator)) }) } } |