From 6356078d193351bff9b7709ceb6cc0620690727d Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Fri, 24 Aug 2018 15:18:47 -0700 Subject: [PATCH] add a few more tests to split function --- template/interpolate/funcs_test.go | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/template/interpolate/funcs_test.go b/template/interpolate/funcs_test.go index 3cc47115f..4e0dcecca 100644 --- a/template/interpolate/funcs_test.go +++ b/template/interpolate/funcs_test.go @@ -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) }