From dfbfb2373037fc6893213c9076c06a2510618bac Mon Sep 17 00:00:00 2001 From: Zach Burgess Date: Wed, 30 Jul 2025 14:22:31 -0700 Subject: [PATCH] Add tests for functions in `functions.go`. --- numeric_test.go | 10 +++++++++- strings_test.go | 14 ++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/numeric_test.go b/numeric_test.go index 1252cd73..d571ec7a 100644 --- a/numeric_test.go +++ b/numeric_test.go @@ -2,9 +2,10 @@ package sprig import ( "fmt" - "github.com/stretchr/testify/assert" "strconv" "testing" + + "github.com/stretchr/testify/assert" ) func TestUntil(t *testing.T) { @@ -249,6 +250,13 @@ func TestDivf(t *testing.T) { } } +func TestMod(t *testing.T) { + tpl := `{{ mod 7 2 }}` + if err := runt(tpl, `1`); err != nil { + t.Error(err) + } +} + func TestMul(t *testing.T) { tpl := `{{ 1 | mul "2" 3 "4"}}` if err := runt(tpl, `24`); err != nil { diff --git a/strings_test.go b/strings_test.go index 28b9a1e8..5694b02e 100644 --- a/strings_test.go +++ b/strings_test.go @@ -297,3 +297,17 @@ func TestPlural(t *testing.T) { t.Error(err) } } + +func TestRepeat(t *testing.T) { + tpl := `{{ "foo" | repeat 5 }}` + if err := runt(tpl, "foofoofoofoofoo"); err != nil { + t.Error(err) + } +} + +func TestSplitList(t *testing.T) { + tpl := `{{ splitList "$" "foo$bar$baz" }}` + if err := runt(tpl, "[foo bar baz]"); err != nil { + t.Error(err) + } +}