diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2020-02-22 10:57:43 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2020-02-22 13:36:04 +0100 |
commit | a524124beb0e7ca226c207ea48a90cea2cbef76e (patch) | |
tree | cf15663aa62b698b32aaf10d2573a7bce0188743 /hugolib/404_test.go | |
parent | c1eb62512446fd80ff5e4c0f45c8614788595e0e (diff) |
Fix crashes for 404 in IsAncestor etc.
Fixes #6931
Diffstat (limited to 'hugolib/404_test.go')
-rw-r--r-- | hugolib/404_test.go | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/hugolib/404_test.go b/hugolib/404_test.go index 6dea9295c..cd203a669 100644 --- a/hugolib/404_test.go +++ b/hugolib/404_test.go @@ -21,15 +21,41 @@ func Test404(t *testing.T) { t.Parallel() b := newTestSitesBuilder(t) - b.WithSimpleConfigFile().WithTemplatesAdded("404.html", "<html><body>Not Found! Parent: {{ .Parent.Kind }}</body></html>") + b.WithSimpleConfigFile().WithTemplatesAdded( + "404.html", + ` +{{ $home := site.Home }} +404: +Parent: {{ .Parent.Kind }} +IsAncestor: {{ .IsAncestor $home }}/{{ $home.IsAncestor . }} +IsDescendant: {{ .IsDescendant $home }}/{{ $home.IsDescendant . }} +CurrentSection: {{ .CurrentSection.Kind }}| +FirstSection: {{ .FirstSection.Kind }}| +InSection: {{ .InSection $home.Section }}|{{ $home.InSection . }} +Sections: {{ len .Sections }}| +Page: {{ .Page.RelPermalink }}| +Data: {{ len .Data }}| + +`, + ) b.Build(BuildCfg{}) // Note: We currently have only 1 404 page. One might think that we should have // multiple, to follow the Custom Output scheme, but I don't see how that would work // right now. b.AssertFileContent("public/404.html", ` -Not Found + + 404: Parent: home +IsAncestor: false/true +IsDescendant: true/false +CurrentSection: home| +FirstSection: home| +InSection: false|true +Sections: 0| +Page: /404.html| +Data: 1| + `) } |