diff options
author | bep <bjorn.erik.pedersen@gmail.com> | 2015-03-06 00:30:51 +0100 |
---|---|---|
committer | bep <bjorn.erik.pedersen@gmail.com> | 2015-03-06 00:48:33 +0100 |
commit | 3343cacc0e5a94ca50537cb5612b5549be2d9ca0 (patch) | |
tree | 7bb57a1dde991052f451ef58d69c651ca17c179e /hugolib/pagination_test.go | |
parent | 6e1b0e0c00ced52979b8629161e36e45d51a47e6 (diff) |
Avoid panic when pagination on 0 pages
Fixes #948
Diffstat (limited to 'hugolib/pagination_test.go')
-rw-r--r-- | hugolib/pagination_test.go | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/hugolib/pagination_test.go b/hugolib/pagination_test.go index 7fb8fa251..5d4612867 100644 --- a/hugolib/pagination_test.go +++ b/hugolib/pagination_test.go @@ -76,10 +76,25 @@ func TestPagerNoPages(t *testing.T) { paginator, _ := newPaginator(pages, 5, urlFactory) paginatorPages := paginator.Pagers() - assert.Equal(t, 0, len(paginatorPages)) + assert.Equal(t, 1, len(paginatorPages)) assert.Equal(t, 0, paginator.TotalNumberOfElements()) assert.Equal(t, 5, paginator.PageSize()) assert.Equal(t, 0, paginator.TotalPages()) + + // pageOne should be nothing but the first + pageOne := paginatorPages[0] + assert.NotNil(t, pageOne.First()) + assert.False(t, pageOne.HasNext()) + assert.False(t, pageOne.HasPrev()) + assert.Nil(t, pageOne.Next()) + assert.Equal(t, 1, len(pageOne.Pagers())) + assert.Equal(t, 0, len(pageOne.Pages())) + assert.Equal(t, 0, pageOne.NumberOfElements()) + assert.Equal(t, 0, pageOne.TotalNumberOfElements()) + assert.Equal(t, 0, pageOne.TotalPages()) + assert.Equal(t, 1, pageOne.PageNumber()) + assert.Equal(t, 5, pageOne.PageSize()) + } func TestPaginationUrlFactory(t *testing.T) { |