diff options
author | Bjørn Erik Pedersen <[email protected]> | 2019-08-03 17:27:40 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2019-08-08 20:13:39 +0200 |
commit | 7ff0a8ee9fe8d710d407e57faf1fda43bd635f28 (patch) | |
tree | 4baa7d913f735cc1089e465b51ff007014bfe25a /hugolib/site_sections_test.go | |
parent | df374851a0683f1446f33a4afef74c42f7d3eaaf (diff) | |
download | hugo-7ff0a8ee9fe8d710d407e57faf1fda43bd635f28.tar.gz hugo-7ff0a8ee9fe8d710d407e57faf1fda43bd635f28.zip |
Simplify page tree logic
This is preparation for #6041.
For historic reasons, the code for bulding the section tree and the taxonomies were very much separate.
This works, but makes it hard to extend, maintain, and possibly not so fast as it could be.
This simplification also introduces 3 slightly breaking changes, which I suspect most people will be pleased about. See referenced issues:
This commit also switches the radix tree dependency to a mutable implementation: github.com/armon/go-radix.
Fixes #6154
Fixes #6153
Fixes #6152
Diffstat (limited to 'hugolib/site_sections_test.go')
-rw-r--r-- | hugolib/site_sections_test.go | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/hugolib/site_sections_test.go b/hugolib/site_sections_test.go index d4aa9d354..2e7ffdf0b 100644 --- a/hugolib/site_sections_test.go +++ b/hugolib/site_sections_test.go @@ -137,21 +137,20 @@ PAG|{{ .Title }}|{{ $sect.InSection . }} }}, {"empty1", func(assert *require.Assertions, p page.Page) { // > b,c - assert.NotNil(getPage(p, "/empty1/b")) + assert.Nil(getPage(p, "/empty1/b")) // No _index.md page. assert.NotNil(getPage(p, "/empty1/b/c")) }}, {"empty2", func(assert *require.Assertions, p page.Page) { - // > b,c,d where b and d have content files. + // > b,c,d where b and d have _index.md files. b := getPage(p, "/empty2/b") assert.NotNil(b) assert.Equal("T40_-1", b.Title()) + c := getPage(p, "/empty2/b/c") + assert.Nil(c) // No _index.md - assert.NotNil(c) - assert.Equal("Cs", c.Title()) d := getPage(p, "/empty2/b/c/d") - assert.NotNil(d) assert.Equal("T41_-1", d.Title()) @@ -163,9 +162,10 @@ PAG|{{ .Title }}|{{ $sect.InSection . }} {"empty3", func(assert *require.Assertions, p page.Page) { // b,c,d with regular page in b b := getPage(p, "/empty3/b") - assert.NotNil(b) - assert.Len(b.Pages(), 1) - assert.Equal("empty3.md", b.Pages()[0].File().LogicalName()) + assert.Nil(b) // No _index.md + e3 := getPage(p, "/empty3/b/empty3") + assert.NotNil(e3) + assert.Equal("empty3.md", e3.File().LogicalName()) }}, {"empty3", func(assert *require.Assertions, p page.Page) { @@ -188,19 +188,23 @@ PAG|{{ .Title }}|{{ $sect.InSection . }} }}, {"l1", func(assert *require.Assertions, p page.Page) { assert.Equal("L1s", p.Title()) - assert.Len(p.Pages(), 2) + assert.Len(p.Pages(), 4) // 2 pages + 2 sections assert.True(p.Parent().IsHome()) assert.Len(p.Sections(), 2) }}, {"l1,l2", func(assert *require.Assertions, p page.Page) { assert.Equal("T2_-1", p.Title()) - assert.Len(p.Pages(), 3) + assert.Len(p.Pages(), 4) // 3 pages + 1 section assert.Equal(p, p.Pages()[0].Parent()) assert.Equal("L1s", p.Parent().Title()) assert.Equal("/l1/l2/", p.RelPermalink()) assert.Len(p.Sections(), 1) for _, child := range p.Pages() { + if child.IsSection() { + assert.Equal(child, child.CurrentSection()) + continue + } assert.Equal(p, child.CurrentSection()) active, err := child.InSection(p) |