summaryrefslogtreecommitdiffstats
path: root/hugolib/paginator_test.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2023-03-08 09:28:46 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2023-03-10 16:34:17 +0100
commit34a86e13f63c1a527e45b5de95696c6937c2043e (patch)
treedff56f07db45b17b7d647c0cbccfdccfeadf5910 /hugolib/paginator_test.go
parent0f01bd46374b13cdc5d7925c913bba777a58bb5b (diff)
Don't fail when calling Paginate with an empty pages.PagesGroup
Fixes #10802
Diffstat (limited to 'hugolib/paginator_test.go')
-rw-r--r--hugolib/paginator_test.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/hugolib/paginator_test.go b/hugolib/paginator_test.go
index a8d8ac8df..fd2321413 100644
--- a/hugolib/paginator_test.go
+++ b/hugolib/paginator_test.go
@@ -136,3 +136,29 @@ weight: %d
b.Assert(b.CheckExists("public/page/1/index.json"), qt.Equals, false)
b.AssertFileContent("public/page/2/index.json", `JSON: 22: |/p11/index.json|/p12/index.json`)
}
+
+// Issue 10802
+func TestPaginatorEmptyPageGroups(t *testing.T) {
+ t.Parallel()
+
+ files := `
+-- config.toml --
+baseURL = "https://example.com/"
+-- content/p1.md --
+-- content/p2.md --
+-- layouts/index.html --
+{{ $empty := site.RegularPages | complement site.RegularPages }}
+Len: {{ len $empty }}: Type: {{ printf "%T" $empty }}
+{{ $pgs := $empty.GroupByPublishDate "January 2006" }}
+{{ $pag := .Paginate $pgs }}
+Len Pag: {{ len $pag.Pages }}
+`
+ b := NewIntegrationTestBuilder(
+ IntegrationTestConfig{
+ T: t,
+ TxtarString: files,
+ },
+ ).Build()
+
+ b.AssertFileContent("public/index.html", "Len: 0", "Len Pag: 0")
+}