tplimpl: Add test with failing partial - hugo - [fork] hugo port for 9front
 (HTM) git clone git@git.drkhsh.at/hugo.git
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) Submodules
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 0aeadfd02ddee35f1fe46eac9b08479742b074b6
 (DIR) parent 5c5efa03d2512749950b0d05a7d4bde35ecbdc37
 (HTM) Author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
       Date:   Sun,  2 Apr 2017 12:06:21 +0200
       
       tplimpl: Add test with failing partial
       
       Main motivation to see that the containing template name is included in the error message name.
       
       It is.
       
       Diffstat:
         M tpl/tplimpl/template_funcs_test.go  |      40 +++++++++++++++++++++++++++++++
       
       1 file changed, 40 insertions(+), 0 deletions(-)
       ---
 (DIR) diff --git a/tpl/tplimpl/template_funcs_test.go b/tpl/tplimpl/template_funcs_test.go
       @@ -2908,6 +2908,46 @@ func TestPartialHTMLAndText(t *testing.T) {
        
        }
        
       +func TestPartialWithError(t *testing.T) {
       +        t.Parallel()
       +        config := newDepsConfig(viper.New())
       +
       +        data := struct {
       +                Name string
       +        }{
       +                Name: "bep",
       +        }
       +
       +        config.WithTemplate = func(templ tpl.TemplateHandler) error {
       +                if err := templ.AddTemplate("container.html", `HTML Test Partial: {{ partial "fail.foo" . -}}`); err != nil {
       +                        return err
       +                }
       +
       +                if err := templ.AddTemplate("partials/fail.foo", "Template: {{ .DoesNotExist }}"); err != nil {
       +                        return err
       +                }
       +
       +                return nil
       +        }
       +
       +        de, err := deps.New(config)
       +        require.NoError(t, err)
       +        require.NoError(t, de.LoadResources())
       +
       +        templ := de.Tmpl.Lookup("container.html")
       +        require.NotNil(t, templ)
       +        result, err := templ.ExecuteToString(data)
       +        require.Error(t, err)
       +
       +        errStr := err.Error()
       +
       +        require.Contains(t, errStr, `template: container.html:1:22: executing "container.html" at <partial "fail.foo" .>`)
       +        require.Contains(t, errStr, `can't evaluate field DoesNotExist`)
       +
       +        require.Empty(t, result)
       +
       +}
       +
        func TestPartialCached(t *testing.T) {
                t.Parallel()
                testCases := []struct {