|
|
|
|
@ -5,13 +5,14 @@ import (
|
|
|
|
|
"io/ioutil"
|
|
|
|
|
"os"
|
|
|
|
|
"reflect"
|
|
|
|
|
"strings"
|
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
"github.com/hashicorp/terraform/config/lang"
|
|
|
|
|
"github.com/hashicorp/terraform/config/lang/ast"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestInterpolateFuncConcat(t *testing.T) {
|
|
|
|
|
func TestInterpolateFuncDeprecatedConcat(t *testing.T) {
|
|
|
|
|
testFunction(t, testFunctionConfig{
|
|
|
|
|
Cases: []testFunctionCase{
|
|
|
|
|
{
|
|
|
|
|
@ -35,6 +36,86 @@ func TestInterpolateFuncConcat(t *testing.T) {
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestInterpolateFuncConcat(t *testing.T) {
|
|
|
|
|
testFunction(t, testFunctionConfig{
|
|
|
|
|
Cases: []testFunctionCase{
|
|
|
|
|
// String + list
|
|
|
|
|
{
|
|
|
|
|
`${concat("a", split(",", "b,c"))}`,
|
|
|
|
|
fmt.Sprintf(
|
|
|
|
|
"%s%s%s%s%s",
|
|
|
|
|
"a",
|
|
|
|
|
InterpSplitDelim,
|
|
|
|
|
"b",
|
|
|
|
|
InterpSplitDelim,
|
|
|
|
|
"c"),
|
|
|
|
|
false,
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// List + string
|
|
|
|
|
{
|
|
|
|
|
`${concat(split(",", "a,b"), "c")}`,
|
|
|
|
|
fmt.Sprintf(
|
|
|
|
|
"%s%s%s%s%s",
|
|
|
|
|
"a",
|
|
|
|
|
InterpSplitDelim,
|
|
|
|
|
"b",
|
|
|
|
|
InterpSplitDelim,
|
|
|
|
|
"c"),
|
|
|
|
|
false,
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// Single list
|
|
|
|
|
{
|
|
|
|
|
`${concat(split(",", ",foo,"))}`,
|
|
|
|
|
fmt.Sprintf(
|
|
|
|
|
"%s%s%s",
|
|
|
|
|
InterpSplitDelim,
|
|
|
|
|
"foo",
|
|
|
|
|
InterpSplitDelim),
|
|
|
|
|
false,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
`${concat(split(",", "a,b,c"))}`,
|
|
|
|
|
fmt.Sprintf(
|
|
|
|
|
"%s%s%s%s%s",
|
|
|
|
|
"a",
|
|
|
|
|
InterpSplitDelim,
|
|
|
|
|
"b",
|
|
|
|
|
InterpSplitDelim,
|
|
|
|
|
"c"),
|
|
|
|
|
false,
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// Two lists
|
|
|
|
|
{
|
|
|
|
|
`${concat(split(",", "a,b,c"), split(",", "d,e"))}`,
|
|
|
|
|
strings.Join([]string{
|
|
|
|
|
"a", "b", "c", "d", "e",
|
|
|
|
|
}, InterpSplitDelim),
|
|
|
|
|
false,
|
|
|
|
|
},
|
|
|
|
|
// Two lists with different separators
|
|
|
|
|
{
|
|
|
|
|
`${concat(split(",", "a,b,c"), split(" ", "d e"))}`,
|
|
|
|
|
strings.Join([]string{
|
|
|
|
|
"a", "b", "c", "d", "e",
|
|
|
|
|
}, InterpSplitDelim),
|
|
|
|
|
false,
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// More lists
|
|
|
|
|
{
|
|
|
|
|
`${concat(split(",", "a,b"), split(",", "c,d"), split(",", "e,f"), split(",", "0,1"))}`,
|
|
|
|
|
strings.Join([]string{
|
|
|
|
|
"a", "b", "c", "d", "e", "f", "0", "1",
|
|
|
|
|
}, InterpSplitDelim),
|
|
|
|
|
false,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestInterpolateFuncFile(t *testing.T) {
|
|
|
|
|
tf, err := ioutil.TempFile("", "tf")
|
|
|
|
|
if err != nil {
|
|
|
|
|
|