forked from mirror/viper
Fix tests broken by mapstructure update
Mapstructure so far returned nil for empty string slices. In a recent version this bug has been fixed: https://github.com/mitchellh/mapstructure/pull/155 Incidentally, this was a bug in Viper too: GetStringSlice and Unmarshal returned with different values. Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
This commit is contained in:
parent
16dc0f72ce
commit
82c2ddf493
|
@ -869,12 +869,13 @@ func TestBindPFlags(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// nolint: dupl
|
||||||
func TestBindPFlagsStringSlice(t *testing.T) {
|
func TestBindPFlagsStringSlice(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
Expected []string
|
Expected []string
|
||||||
Value string
|
Value string
|
||||||
}{
|
}{
|
||||||
{nil, ""},
|
{[]string{}, ""},
|
||||||
{[]string{"jeden"}, "jeden"},
|
{[]string{"jeden"}, "jeden"},
|
||||||
{[]string{"dwa", "trzy"}, "dwa,trzy"},
|
{[]string{"dwa", "trzy"}, "dwa,trzy"},
|
||||||
{[]string{"cztery", "piec , szesc"}, "cztery,\"piec , szesc\""},
|
{[]string{"cztery", "piec , szesc"}, "cztery,\"piec , szesc\""},
|
||||||
|
@ -908,6 +909,7 @@ func TestBindPFlagsStringSlice(t *testing.T) {
|
||||||
}
|
}
|
||||||
if changed {
|
if changed {
|
||||||
assert.Equal(t, testValue.Expected, val.StringSlice)
|
assert.Equal(t, testValue.Expected, val.StringSlice)
|
||||||
|
assert.Equal(t, testValue.Expected, v.Get("stringslice"))
|
||||||
} else {
|
} else {
|
||||||
assert.Equal(t, defaultVal, val.StringSlice)
|
assert.Equal(t, defaultVal, val.StringSlice)
|
||||||
}
|
}
|
||||||
|
@ -915,12 +917,13 @@ func TestBindPFlagsStringSlice(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// nolint: dupl
|
||||||
func TestBindPFlagsIntSlice(t *testing.T) {
|
func TestBindPFlagsIntSlice(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
Expected []int
|
Expected []int
|
||||||
Value string
|
Value string
|
||||||
}{
|
}{
|
||||||
{nil, ""},
|
{[]int{}, ""},
|
||||||
{[]int{1}, "1"},
|
{[]int{1}, "1"},
|
||||||
{[]int{2, 3}, "2,3"},
|
{[]int{2, 3}, "2,3"},
|
||||||
}
|
}
|
||||||
|
@ -953,6 +956,7 @@ func TestBindPFlagsIntSlice(t *testing.T) {
|
||||||
}
|
}
|
||||||
if changed {
|
if changed {
|
||||||
assert.Equal(t, testValue.Expected, val.IntSlice)
|
assert.Equal(t, testValue.Expected, val.IntSlice)
|
||||||
|
assert.Equal(t, testValue.Expected, v.Get("intslice"))
|
||||||
} else {
|
} else {
|
||||||
assert.Equal(t, defaultVal, val.IntSlice)
|
assert.Equal(t, defaultVal, val.IntSlice)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue