Merge pull request #6628 from hashicorp/follow_on_6357

add a few more tests to split function
This commit is contained in:
Megan Marsh 2018-08-24 15:34:16 -07:00 committed by GitHub
commit fa6c316e55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 3 deletions

View File

@ -202,12 +202,24 @@ func TestFuncTemplatePath(t *testing.T) {
func TestFuncSplit(t *testing.T) {
cases := []struct {
Input string
Output string
Input string
Output string
ErrorExpected bool
}{
{
`{{split build_name "-" 0}}`,
"foo",
false,
},
{
`{{split build_name "-" 1}}`,
"bar",
false,
},
{
`{{split build_name "-" 2}}`,
"",
true,
},
}
@ -215,7 +227,7 @@ func TestFuncSplit(t *testing.T) {
for _, tc := range cases {
i := &I{Value: tc.Input}
result, err := i.Render(ctx)
if err != nil {
if (err == nil) == tc.ErrorExpected {
t.Fatalf("Input: %s\n\nerr: %s", tc.Input, err)
}