aboutsummaryrefslogtreecommitdiffhomepage
path: root/hugolib/page_test.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2019-03-25 18:18:34 +0100
committerBjørn Erik Pedersen <[email protected]>2019-03-26 10:20:40 +0100
commit4dae52af680e6ff2c8cdeb4ce1f219330b27001c (patch)
treedb157b09fc15b25a07512581fbd80536fe8e18ee /hugolib/page_test.go
parent794d4052b87c98943588b35e1cfecc06e6a0c7f2 (diff)
downloadhugo-4dae52af680e6ff2c8cdeb4ce1f219330b27001c.tar.gz
hugo-4dae52af680e6ff2c8cdeb4ce1f219330b27001c.zip
Avoid nilpointer on no File on Page
Fixes #5781
Diffstat (limited to 'hugolib/page_test.go')
-rw-r--r--hugolib/page_test.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/hugolib/page_test.go b/hugolib/page_test.go
index 5e9ac696c..1e362e0dc 100644
--- a/hugolib/page_test.go
+++ b/hugolib/page_test.go
@@ -18,6 +18,8 @@ import (
"html/template"
"os"
+ "github.com/gohugoio/hugo/common/loggers"
+
"path/filepath"
"strings"
"testing"
@@ -1166,6 +1168,12 @@ Content:{{ .Content }}
}
+// https://github.com/gohugoio/hugo/issues/5781
+func TestPageWithZeroFile(t *testing.T) {
+ newTestSitesBuilder(t).WithLogger(loggers.NewWarningLogger()).WithSimpleConfigFile().
+ WithTemplatesAdded("index.html", "{{ .File.Filename }}{{ with .File }}{{ .Dir }}{{ end }}").Build(BuildCfg{})
+}
+
func TestShouldBuild(t *testing.T) {
t.Parallel()
var past = time.Date(2009, 11, 17, 20, 34, 58, 651387237, time.UTC)