mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-21 21:35:28 +02:00
@@ -52,6 +52,7 @@ func preparePageGroupTestPages(t *testing.T) Pages {
|
||||
p.lastMod = cast.ToTime(src.date).AddDate(3, 0, 0)
|
||||
p.params["custom_param"] = src.param
|
||||
p.params["custom_date"] = cast.ToTime(src.date)
|
||||
p.params["custom_string_date"] = src.date
|
||||
pages = append(pages, p)
|
||||
}
|
||||
return pages
|
||||
@@ -379,6 +380,25 @@ func TestGroupByParamDate(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// https://github.com/gohugoio/hugo/issues/3983
|
||||
func TestGroupByParamDateWithStringParams(t *testing.T) {
|
||||
t.Parallel()
|
||||
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.GroupByParamDate("custom_string_date", "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 TestGroupByLastmod(t *testing.T) {
|
||||
t.Parallel()
|
||||
pages := preparePageGroupTestPages(t)
|
||||
|
Reference in New Issue
Block a user