summaryrefslogtreecommitdiffhomepage
path: root/hugolib/site_sections_test.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2018-11-28 12:36:59 +0100
committerBjørn Erik Pedersen <[email protected]>2018-11-28 12:36:59 +0100
commitb09a40333f382cc1034d2eda856230258ab6b8cc (patch)
tree8a1da80b3b6a03806f5891f9384d445a6e41d5f2 /hugolib/site_sections_test.go
parent7540a62834d4465af8936967e430a9e05a1e1359 (diff)
downloadhugo-b09a40333f382cc1034d2eda856230258ab6b8cc.tar.gz
hugo-b09a40333f382cc1034d2eda856230258ab6b8cc.zip
hugolib: Improve nil handling in IsDescendant and IsAncestor
Fixes #5461
Diffstat (limited to 'hugolib/site_sections_test.go')
-rw-r--r--hugolib/site_sections_test.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/hugolib/site_sections_test.go b/hugolib/site_sections_test.go
index 24bb6a91f..1987d2bcb 100644
--- a/hugolib/site_sections_test.go
+++ b/hugolib/site_sections_test.go
@@ -238,6 +238,8 @@ PAG|{{ .Title }}|{{ $sect.InSection . }}
assert.Len(p.Sections(), 0)
}},
{"l1,l2,l3", func(p *Page) {
+ var nilp *Page
+
assert.Equal("T3_-1", p.title)
assert.Len(p.Pages, 2)
assert.Equal("T2_-1", p.Parent().title)
@@ -247,6 +249,12 @@ PAG|{{ .Title }}|{{ $sect.InSection . }}
isDescendant, err := l1.IsDescendant(p)
assert.NoError(err)
assert.False(isDescendant)
+ isDescendant, err = l1.IsDescendant(nil)
+ assert.NoError(err)
+ assert.False(isDescendant)
+ isDescendant, err = nilp.IsDescendant(p)
+ assert.NoError(err)
+ assert.False(isDescendant)
isDescendant, err = p.IsDescendant(l1)
assert.NoError(err)
assert.True(isDescendant)
@@ -258,6 +266,12 @@ PAG|{{ .Title }}|{{ $sect.InSection . }}
assert.NoError(err)
assert.False(isAncestor)
assert.Equal(l1, p.FirstSection())
+ isAncestor, err = p.IsAncestor(nil)
+ assert.NoError(err)
+ assert.False(isAncestor)
+ isAncestor, err = nilp.IsAncestor(l1)
+ assert.NoError(err)
+ assert.False(isAncestor)
}},
{"perm a,link", func(p *Page) {