mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-28 22:19:59 +02:00
tpl/collections: Fix apply when function have Context as first arg
As introduced in `partial` and `partialCached` in Hugo 0.93.0. Fixes #9585
This commit is contained in:
@@ -73,21 +73,23 @@ func TestApply(t *testing.T) {
|
||||
|
||||
strings := []interface{}{"a\n", "b\n"}
|
||||
|
||||
result, err := ns.Apply(strings, "print", "a", "b", "c")
|
||||
ctx := context.Background()
|
||||
|
||||
result, err := ns.Apply(ctx, strings, "print", "a", "b", "c")
|
||||
c.Assert(err, qt.IsNil)
|
||||
c.Assert(result, qt.DeepEquals, []interface{}{"abc", "abc"})
|
||||
|
||||
_, err = ns.Apply(strings, "apply", ".")
|
||||
_, err = ns.Apply(ctx, strings, "apply", ".")
|
||||
c.Assert(err, qt.Not(qt.IsNil))
|
||||
|
||||
var nilErr *error
|
||||
_, err = ns.Apply(nilErr, "chomp", ".")
|
||||
_, err = ns.Apply(ctx, nilErr, "chomp", ".")
|
||||
c.Assert(err, qt.Not(qt.IsNil))
|
||||
|
||||
_, err = ns.Apply(strings, "dobedobedo", ".")
|
||||
_, err = ns.Apply(ctx, strings, "dobedobedo", ".")
|
||||
c.Assert(err, qt.Not(qt.IsNil))
|
||||
|
||||
_, err = ns.Apply(strings, "foo.Chomp", "c\n")
|
||||
_, err = ns.Apply(ctx, strings, "foo.Chomp", "c\n")
|
||||
if err == nil {
|
||||
t.Errorf("apply with unknown func should fail")
|
||||
}
|
||||
|
Reference in New Issue
Block a user