common: add test for empty val

This commit is contained in:
Mitchell Hashimoto 2014-05-06 18:52:02 -07:00
parent 675c51e47d
commit 34834057c3
1 changed files with 7 additions and 2 deletions

View File

@ -99,7 +99,8 @@ func TestDecodeConfig(t *testing.T) {
// configuration.
func TestDecodeConfig_stringToSlice(t *testing.T) {
type Local struct {
Val []string
Val []string
EmptyVal []string
}
raw := map[string]interface{}{
@ -107,7 +108,8 @@ func TestDecodeConfig_stringToSlice(t *testing.T) {
"foo": "bar",
},
"val": "foo,{{user `foo`}}",
"val": "foo,{{user `foo`}}",
"emptyval": "",
}
var result Local
@ -120,6 +122,9 @@ func TestDecodeConfig_stringToSlice(t *testing.T) {
if !reflect.DeepEqual(result.Val, expected) {
t.Fatalf("invalid: %#v", result.Val)
}
if len(result.EmptyVal) > 0 {
t.Fatalf("invalid: %#v", result.EmptyVal)
}
}
// This test tests the case that a user var is used for an integer