feat: articles pagination
This commit is contained in:
1 parent
a2d224240c
commit
73f4b539fe
45 files changed
+3528
-317
No files matched your search
@@ -196,35 +196,36 @@ func TestListArticlesFiltersByIsOnline(t *testing.T) {
|
||||
return repo
|
||||
}
|
||||
|
||||
t.Run("ListOnlineArticles", func(t *testing.T) {
|
||||
t.Run("ListArticlesPage unverified", func(t *testing.T) {
|
||||
repo := newRepo()
|
||||
uc := useCases.NewListArticlesUseCase(repo, &fakeBodyRenderer{})
|
||||
result, err := uc.ListOnlineArticles(article.BodyFormatHTML)
|
||||
result, err := uc.ListArticlesPage(useCases.ListArticlesCommand{Format: article.BodyFormatHTML, Page: 1, Size: 25, Sort: article.Sort{Field: article.SortByTitle, Direction: article.SortAsc}})
|
||||
if err != nil {
|
||||
t.Fatalf("expected no error, got %v", err)
|
||||
}
|
||||
assertArticleIds(t, result, []uint32{1, 3})
|
||||
assertArticleIds(t, result.Items, []uint32{1, 3})
|
||||
})
|
||||
|
||||
t.Run("ListAllArticles", func(t *testing.T) {
|
||||
t.Run("ListArticlesPage verified", func(t *testing.T) {
|
||||
repo := newRepo()
|
||||
uc := useCases.NewListArticlesUseCase(repo, &fakeBodyRenderer{})
|
||||
result, err := uc.ListAllArticles(article.BodyFormatHTML)
|
||||
result, err := uc.ListArticlesPage(useCases.ListArticlesCommand{Format: article.BodyFormatHTML, Verified: true, Page: 1, Size: 25, Sort: article.Sort{Field: article.SortByTitle, Direction: article.SortAsc}})
|
||||
if err != nil {
|
||||
t.Fatalf("expected no error, got %v", err)
|
||||
}
|
||||
assertArticleIds(t, result, []uint32{1, 2, 3})
|
||||
assertArticleIds(t, result.Items, []uint32{1, 2, 3})
|
||||
})
|
||||
}
|
||||
|
||||
func TestListOnlineArticlesEmptyRepositoryReturnsEmptySlice(t *testing.T) {
|
||||
func TestListArticlesPageEmptyRepositoryReturnsEmptySlice(t *testing.T) {
|
||||
repo := newMockArticleRepo()
|
||||
uc := useCases.NewListArticlesUseCase(repo, &fakeBodyRenderer{})
|
||||
|
||||
result, err := uc.ListOnlineArticles(article.BodyFormatHTML)
|
||||
page, err := uc.ListArticlesPage(useCases.ListArticlesCommand{Format: article.BodyFormatHTML, Verified: true, Page: 1, Size: 25})
|
||||
if err != nil {
|
||||
t.Fatalf("expected no error, got %v", err)
|
||||
}
|
||||
result := page.Items
|
||||
if result == nil {
|
||||
t.Errorf("expected an empty slice, got nil")
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user