diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-03-25 14:37:04 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-03-27 15:43:56 +0200 |
commit | 15b64d51da48807c5f896f17b33d8c0d054c9461 (patch) | |
tree | b8f585ad5a1741b26540184ec29ec2a26fc4060f /tpl | |
parent | 148fedd227b8f4f5af8f72cb6841653140f82dfe (diff) |
all: Propagate baseURL error to the callers
Diffstat (limited to 'tpl')
-rw-r--r-- | tpl/tplimpl/template_funcs_test.go | 27 | ||||
-rw-r--r-- | tpl/tplimpl/template_test.go | 10 |
2 files changed, 25 insertions, 12 deletions
diff --git a/tpl/tplimpl/template_funcs_test.go b/tpl/tplimpl/template_funcs_test.go index aa322dded..a9cf5e58b 100644 --- a/tpl/tplimpl/template_funcs_test.go +++ b/tpl/tplimpl/template_funcs_test.go @@ -289,12 +289,16 @@ urlize: bat-man } config.Fs = fs - d := deps.New(config) + d, err := deps.New(config) + if err != nil { + t.Fatal(err) + } + if err := d.LoadResources(); err != nil { t.Fatal(err) } - err := d.Tmpl.Lookup("test").Execute(&b, &data) + err = d.Tmpl.Lookup("test").Execute(&b, &data) if err != nil { t.Fatal("Got error on execute", err) @@ -2902,12 +2906,13 @@ func TestPartialCached(t *testing.T) { return nil } - de := deps.New(config) + de, err := deps.New(config) + require.NoError(t, err) require.NoError(t, de.LoadResources()) buf := new(bytes.Buffer) templ := de.Tmpl.Lookup("testroot") - err := templ.Execute(buf, &data) + err = templ.Execute(buf, &data) if err != nil { t.Fatalf("[%d] error executing template: %s", i, err) } @@ -2941,7 +2946,8 @@ func BenchmarkPartial(b *testing.B) { return nil } - de := deps.New(config) + de, err := deps.New(config) + require.NoError(b, err) require.NoError(b, de.LoadResources()) buf := new(bytes.Buffer) @@ -2972,7 +2978,8 @@ func BenchmarkPartialCached(b *testing.B) { return nil } - de := deps.New(config) + de, err := deps.New(config) + require.NoError(b, err) require.NoError(b, de.LoadResources()) buf := new(bytes.Buffer) @@ -2994,7 +3001,10 @@ func newTestFuncster() *templateFuncster { func newTestFuncsterWithViper(v *viper.Viper) *templateFuncster { config := newDepsConfig(v) - d := deps.New(config) + d, err := deps.New(config) + if err != nil { + panic(err) + } if err := d.LoadResources(); err != nil { panic(err) @@ -3013,7 +3023,8 @@ func newTestTemplate(t *testing.T, name, template string) *template.Template { return nil } - de := deps.New(config) + de, err := deps.New(config) + require.NoError(t, err) require.NoError(t, de.LoadResources()) return de.Tmpl.Lookup(name) diff --git a/tpl/tplimpl/template_test.go b/tpl/tplimpl/template_test.go index 08bcab1a7..43b834df2 100644 --- a/tpl/tplimpl/template_test.go +++ b/tpl/tplimpl/template_test.go @@ -79,7 +79,8 @@ html lang=en []byte(this.baseContent), []byte(this.innerContent)) } - a := deps.New(config) + a, err := deps.New(config) + require.NoError(t, err) if err := a.LoadResources(); err != nil { t.Fatal(err) @@ -94,7 +95,7 @@ html lang=en } var buff bytes.Buffer - err := a.Tmpl.ExecuteTemplate(&buff, "mytemplate.html", d) + err = a.Tmpl.ExecuteTemplate(&buff, "mytemplate.html", d) if err != nil && this.expectErr == 0 { t.Errorf("Test %d with root '%s' errored: %s", i, root, err) @@ -288,7 +289,8 @@ func TestTplGoFuzzReports(t *testing.T) { return templ.AddTemplate("fuzz", this.data) } - de := deps.New(config) + de, err := deps.New(config) + require.NoError(t, err) require.NoError(t, de.LoadResources()) templ := de.Tmpl.(*GoHTMLTemplate) @@ -299,7 +301,7 @@ func TestTplGoFuzzReports(t *testing.T) { t.Errorf("#1 Test %d should have errored", i) } - err := de.Tmpl.ExecuteTemplate(ioutil.Discard, "fuzz", d) + err = de.Tmpl.ExecuteTemplate(ioutil.Discard, "fuzz", d) if err != nil && this.expectErr == 0 { t.Fatalf("Test %d errored: %s", i, err) |