add a few more tests to split function
This commit is contained in:
parent
8fbce8c40c
commit
6356078d19
|
@ -204,10 +204,22 @@ func TestFuncSplit(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
Input string
|
Input string
|
||||||
Output string
|
Output string
|
||||||
|
ErrorExpected bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
`{{split build_name "-" 0}}`,
|
`{{split build_name "-" 0}}`,
|
||||||
"foo",
|
"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 {
|
for _, tc := range cases {
|
||||||
i := &I{Value: tc.Input}
|
i := &I{Value: tc.Input}
|
||||||
result, err := i.Render(ctx)
|
result, err := i.Render(ctx)
|
||||||
if err != nil {
|
if (err == nil) == tc.ErrorExpected {
|
||||||
t.Fatalf("Input: %s\n\nerr: %s", tc.Input, err)
|
t.Fatalf("Input: %s\n\nerr: %s", tc.Input, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue