From 735803ef0995833bfd042d9c7c5832aa37cdcf18 Mon Sep 17 00:00:00 2001 From: Anthony Stanton Date: Tue, 15 Sep 2015 15:50:31 +0200 Subject: [PATCH] Test cases for compact() --- config/interpolate_funcs_test.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/config/interpolate_funcs_test.go b/config/interpolate_funcs_test.go index e4d275e580..e3564aee1e 100644 --- a/config/interpolate_funcs_test.go +++ b/config/interpolate_funcs_test.go @@ -11,6 +11,34 @@ import ( "github.com/hashicorp/terraform/config/lang/ast" ) + +func TestInterpolateFuncCompact(t *testing.T) { + testFunction(t, testFunctionConfig{ + Cases: []testFunctionCase{ + // empty string within array + { + `${compact(split(",", "b,,c"))}`, + NewStringList([]string{"b", "c"}).String(), + false, + }, + + // empty string at the end of array + { + `${compact(split(",", "b,c,"))}`, + NewStringList([]string{"b", "c"}).String(), + false, + }, + + // single empty string + { + `${compact(split(",", ""))}`, + NewStringList([]string{}).String(), + false, + }, + }, + }) +} + func TestInterpolateFuncDeprecatedConcat(t *testing.T) { testFunction(t, testFunctionConfig{ Cases: []testFunctionCase{