Complete refactor of indexes, move (and rewrite) page sorting to page.go, add tests

This commit is contained in:
spf13
2013-12-20 09:10:05 -05:00
parent 6aa3e51228
commit 70745e8cb5
4 changed files with 229 additions and 147 deletions

View File

@@ -355,7 +355,7 @@ weight = "4"
title = "Four"
date = "2012-01-01"
+++
Front Matter with Ordered Pages 4`)
Front Matter with Ordered Pages 4. This is longer content`)
var WEIGHTED_SOURCES = []source.ByteSource{
{"sect/doc1.md", WEIGHTED_PAGE_1, "sect"},
@@ -389,6 +389,27 @@ func TestOrderedPages(t *testing.T) {
if s.Sections["sect"][1].Page.Title != "Three" || s.Sections["sect"][2].Page.Title != "Four" {
t.Errorf("Pages in unexpected order. Second should be '%s', got '%s'", "Three", s.Sections["sect"][1].Page.Title)
}
bydate := s.Pages.ByDate()
if bydate[0].Title != "One" {
t.Errorf("Pages in unexpected order. First should be '%s', got '%s'", "One", bydate[0].Title)
}
rev := bydate.Reverse()
if rev[0].Title != "Three" {
t.Errorf("Pages in unexpected order. First should be '%s', got '%s'", "Three", rev[0].Title)
}
bylength := s.Pages.ByLength()
if bylength[0].Title != "One" {
t.Errorf("Pages in unexpected order. First should be '%s', got '%s'", "One", bylength[0].Title)
}
rbylength := bylength.Reverse()
if rbylength[0].Title != "Four" {
t.Errorf("Pages in unexpected order. First should be '%s', got '%s'", "Four", rbylength[0].Title)
}
}
var PAGE_WITH_WEIGHTED_INDEXES_2 = []byte(`+++