🩹Fix render test

pull/614/head
Fenny 2020-07-15 14:49:01 +02:00
parent 32cd3e225f
commit d1b80af26e
2 changed files with 4 additions and 3 deletions

1
.github/single.tmpl vendored Normal file
View File

@ -0,0 +1 @@
<h1>{{.Title}}</h1>

View File

@ -1396,10 +1396,11 @@ func Test_Ctx_Redirect(t *testing.T) {
// go test -run Test_Ctx_Render
func Test_Ctx_Render(t *testing.T) {
t.Parallel()
app := New()
ctx := app.AcquireCtx(&fasthttp.RequestCtx{})
defer app.ReleaseCtx(ctx)
err := ctx.Render("./.github/index.tmpl", Map{
err := ctx.Render("./.github/single.tmpl", Map{
"Title": "Hello, World!",
})
utils.AssertEqual(t, nil, err)
@ -1416,14 +1417,13 @@ func (t *testTemplateEngine) Render(w io.Writer, name string, bind interface{},
}
func (t *testTemplateEngine) Load() error {
t.mu.Lock()
defer t.mu.Unlock()
t.templates = template.Must(template.ParseGlob("./.github/*.tmpl"))
return nil
}
// go test -run Test_Ctx_Render_Engine
func Test_Ctx_Render_Engine(t *testing.T) {
t.Parallel()
engine := &testTemplateEngine{}
engine.Load()
app := New()