summaryrefslogtreecommitdiffstats
path: root/hugolib
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2015-07-25 17:22:19 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2015-07-25 17:22:46 +0200
commit40efc8677a2923ddd7ab99d29516ad0f5e859c28 (patch)
tree5fe94e7292d7d87111e08402c4aecc48aca9e46d /hugolib
parent36e0d005ed5bc680c5816abd1917dd392b7b92de (diff)
Fix sort test and title sort
See #1299
Diffstat (limited to 'hugolib')
-rw-r--r--hugolib/pageSort.go2
-rw-r--r--hugolib/pageSort_test.go10
2 files changed, 6 insertions, 6 deletions
diff --git a/hugolib/pageSort.go b/hugolib/pageSort.go
index b4bc9d2a3..99c01f630 100644
--- a/hugolib/pageSort.go
+++ b/hugolib/pageSort.go
@@ -44,7 +44,7 @@ func (by PageBy) Sort(pages Pages) {
var DefaultPageSort = func(p1, p2 *Page) bool {
if p1.Weight == p2.Weight {
if p1.Date.Unix() == p2.Date.Unix() {
- return strings.Compare(p1.LinkTitle(), p2.LinkTitle()) == 1
+ return strings.Compare(p1.LinkTitle(), p2.LinkTitle()) == -1
}
return p1.Date.Unix() > p2.Date.Unix()
}
diff --git a/hugolib/pageSort_test.go b/hugolib/pageSort_test.go
index 4a16ab87d..20c025961 100644
--- a/hugolib/pageSort_test.go
+++ b/hugolib/pageSort_test.go
@@ -10,16 +10,16 @@ import (
"github.com/spf13/hugo/source"
)
-func TesDefaultSort(t *testing.T) {
+func TestDefaultSort(t *testing.T) {
d1 := time.Now()
- d2 := d1.Add(1 * time.Hour)
- d3 := d1.Add(2 * time.Hour)
+ d2 := d1.Add(-1 * time.Hour)
+ d3 := d1.Add(-2 * time.Hour)
p := createSortTestPages(3)
// first by weight
- setSortVals([3]time.Time{d1, d2, d3}, [3]string{"a", "b", "c"}, [3]int{3, 2, 1}, p)
+ setSortVals([3]time.Time{d1, d2, d3}, [3]string{"b", "a", "c"}, [3]int{3, 2, 1}, p)
p.Sort()
assert.Equal(t, 1, p[0].Weight)
@@ -29,7 +29,7 @@ func TesDefaultSort(t *testing.T) {
assert.Equal(t, d1, p[0].Date)
// finally by title
- setSortVals([3]time.Time{d3, d3, d3}, [3]string{"b", "a", "c"}, [3]int{1, 1, 1}, p)
+ setSortVals([3]time.Time{d3, d3, d3}, [3]string{"b", "c", "a"}, [3]int{1, 1, 1}, p)
p.Sort()
assert.Equal(t, "a", p[0].Title)
assert.Equal(t, "b", p[1].Title)