Folders: Add pagination to list (#102334)

This commit is contained in:
Stephanie Hingtgen
2025-03-18 04:56:06 -06:00
committed by GitHub
parent ba44ceb4b2
commit c79c768421
6 changed files with 105 additions and 8 deletions
@@ -878,7 +878,7 @@ func TestIntegrationGetFolders(t *testing.T) {
for i := 0; i < foldersNum; i++ {
uid := util.GenerateShortUID()
f, err := folderStore.Create(context.Background(), folder.CreateFolderCommand{
Title: folderTitle,
Title: folderTitle + fmt.Sprintf("-%d", i),
Description: folderDsc,
OrgID: orgID,
UID: uid,
@@ -982,6 +982,23 @@ func TestIntegrationGetFolders(t *testing.T) {
assert.NotEmpty(t, actualFolder.Updated)
assert.NotEmpty(t, actualFolder.URL)
})
t.Run("get folders with limit and page should work as expected", func(t *testing.T) {
q := folder.NewGetFoldersQuery(folder.GetFoldersQuery{
OrgID: orgID,
UIDs: uids,
Limit: 3,
Page: 2,
})
actualFolders, err := folderStore.GetFolders(context.Background(), q)
require.NoError(t, err)
assert.Equal(t, 3, len(actualFolders))
for i, actualFolder := range actualFolders {
assert.Equal(t, fmt.Sprintf("folder1-%d", i+3), actualFolder.Title)
}
})
}
func CreateOrg(t *testing.T, db db.DB, cfg *setting.Cfg) int64 {