diff options
author | Hanchen Wang <hanchen.wang@mail.utoronto.ca> | 2016-05-11 10:09:43 -0400 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2016-06-14 15:45:26 +0200 |
commit | c1c8ecc9d6df31830a64618cb04f79ae34a3335a (patch) | |
tree | 2fd681ad2f76739d82b0c2540149f22f49620e25 /hugolib/pageGroup_test.go | |
parent | 091915c75d20c07384936fbc968e04f959ea7578 (diff) |
hugolib: Add GroupByExpireDate function
Diffstat (limited to 'hugolib/pageGroup_test.go')
-rw-r--r-- | hugolib/pageGroup_test.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/hugolib/pageGroup_test.go b/hugolib/pageGroup_test.go index c9b3cfaa8..e7a975172 100644 --- a/hugolib/pageGroup_test.go +++ b/hugolib/pageGroup_test.go @@ -47,6 +47,7 @@ func preparePageGroupTestPages(t *testing.T) Pages { p.Weight = s.weight p.Date = cast.ToTime(s.date) p.PublishDate = cast.ToTime(s.date) + p.ExpiryDate = cast.ToTime(s.date) p.Params["custom_param"] = s.param p.Params["custom_date"] = cast.ToTime(s.date) pages = append(pages, p) @@ -369,6 +370,23 @@ func TestGroupByPublishDateWithEmptyPages(t *testing.T) { } } +func TestGroupByExpiryDate(t *testing.T) { + pages := preparePageGroupTestPages(t) + expect := PagesGroup{ + {Key: "2012-04", Pages: Pages{pages[4], pages[2], pages[0]}}, + {Key: "2012-03", Pages: Pages{pages[3]}}, + {Key: "2012-01", Pages: Pages{pages[1]}}, + } + + groups, err := pages.GroupByExpiryDate("2006-01") + if err != nil { + t.Fatalf("Unable to make PagesGroup array: %s", err) + } + if !reflect.DeepEqual(groups, expect) { + t.Errorf("PagesGroup has unexpected groups. It should be %#v, got %#v", expect, groups) + } +} + func TestGroupByParamDate(t *testing.T) { pages := preparePageGroupTestPages(t) expect := PagesGroup{ |