diff --git a/os/gview/gview_z_unit_test.go b/os/gview/gview_z_unit_test.go
index c055d3fde..f81a38700 100644
--- a/os/gview/gview_z_unit_test.go
+++ b/os/gview/gview_z_unit_test.go
@@ -216,15 +216,19 @@ func Test_FuncNl2Br(t *testing.T) {
func Test_FuncInclude(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
- header := `
HEADER
`
- main := `hello gf
`
- footer := `FOOTER
`
- layout := `{{include "header.html" .}}
+ var (
+ header = `HEADER
`
+ main = `hello gf
`
+ footer = `FOOTER
`
+ layout = `{{include "header.html" .}}
{{include "main.html" .}}
{{include "footer.html" .}}`
- templatePath := gfile.Pwd() + gfile.Separator + "template"
+ templatePath = gfile.Pwd() + gfile.Separator + "template"
+ )
+
gfile.Mkdir(templatePath)
defer gfile.Remove(templatePath)
+
// headerFile, _ := gfile.Create(templatePath + gfile.Separator + "header.html")
err := ioutil.WriteFile(templatePath+gfile.Separator+"header.html", []byte(header), 0644)
if err != nil {
@@ -235,19 +239,21 @@ func Test_FuncInclude(t *testing.T) {
ioutil.WriteFile(templatePath+gfile.Separator+"layout.html", []byte(layout), 0644)
view := gview.New(templatePath)
result, err := view.Parse(context.TODO(), "notfound.html")
- t.Assert(err != nil, true)
+ t.AssertNE(err, nil)
t.Assert(result, ``)
+
result, err = view.Parse(context.TODO(), "layout.html")
- t.Assert(err != nil, false)
+ t.AssertNil(err)
t.Assert(result, `HEADER
hello gf
FOOTER
`)
+
notfoundPath := templatePath + gfile.Separator + "template" + gfile.Separator + "notfound.html"
gfile.Mkdir(templatePath + gfile.Separator + "template")
gfile.Create(notfoundPath)
ioutil.WriteFile(notfoundPath, []byte("notfound"), 0644)
result, err = view.Parse(context.TODO(), "notfound.html")
- t.Assert(err != nil, true)
+ t.AssertNE(err, nil)
t.Assert(result, ``)
})
}