From 34834057c3b8a65c3b62b2d2b74263a6393b1c75 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 6 May 2014 18:52:02 -0700 Subject: [PATCH] common: add test for empty val --- common/config_test.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/common/config_test.go b/common/config_test.go index 1108ccb18..a93feb729 100644 --- a/common/config_test.go +++ b/common/config_test.go @@ -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