feat(media): pagination

This commit is contained in:
Florian Sylvain committed 2026-10-13 19:54:59 +02:00
1 parent 04dc151ed7
commit 63c1e7076e
65 files changed
+2960 -365

No files matched your search

+5 -7
View File
@@ -5,7 +5,6 @@ import (
"RenewCMS/internal/domain/article"
domain "RenewCMS/internal/domain/image"
"net/http"
"net/url"
"slices"
"strings"
"testing"
@@ -184,16 +183,15 @@ func TestMediaListVariantsFilterAndSort(t *testing.T) {
}
})
t.Run("variants=with and sort=total_size page through the list", func(t *testing.T) {
t.Run("variants=with and sort=total_size answer the ordered page with its total", func(t *testing.T) {
env := newVariantEnv(t)
env.seedLibrary()
first, firstBody := env.listIds("?variants=with&sort=total_size&limit=2")
cursor, _ := firstBody["next_cursor"].(string)
second, secondBody := env.listIds("?variants=with&sort=total_size&limit=2&cursor=" + url.QueryEscape(cursor))
ids, body := env.listIds("?variants=with&sort=total_size&size=5&page=1")
beyond, _ := env.listIds("?variants=with&sort=total_size&size=5&page=2")
if !slices.Equal(first, []float64{1, 4}) || cursor == "" || !slices.Equal(second, []float64{2}) || secondBody["next_cursor"] != nil {
t.Errorf("first = %v (%q), second = %v (%v)", first, cursor, second, secondBody["next_cursor"])
if !slices.Equal(ids, []float64{1, 4, 2}) || body["total"] != float64(3) || len(beyond) != 0 {
t.Errorf("ids = %v, total = %v, beyond = %v", ids, body["total"], beyond)
}
})