fix(uploads): serialize status filters and resize oversized covers
ci / module boundaries / boundaries (push) Successful in 9s
ci / contract / contract (сгенерированный код совпадает с openapi.yaml) (push) Successful in 1m37s
ci / api / api (push) Successful in 58s
ci / mobile / mobile (Metro-бандл Android) (push) Successful in 1m22s
ci / db / db (push) Successful in 6m19s
ci / ts / ts (packages + web) (push) Failing after 27m2s
ci / module boundaries / boundaries (push) Successful in 9s
ci / contract / contract (сгенерированный код совпадает с openapi.yaml) (push) Successful in 1m37s
ci / api / api (push) Successful in 58s
ci / mobile / mobile (Metro-бандл Android) (push) Successful in 1m22s
ci / db / db (push) Successful in 6m19s
ci / ts / ts (packages + web) (push) Failing after 27m2s
This commit is contained in:
1 parent
ca2a50b515
commit
e78cab6ce6
11 files changed
+152
-17
No files matched your search
@@ -0,0 +1,38 @@
|
||||
package uploads
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"pipu/api/internal/api/gen"
|
||||
)
|
||||
|
||||
type uploadQueryHandler struct {
|
||||
gen.Unimplemented
|
||||
statuses []gen.UploadStatus
|
||||
}
|
||||
|
||||
func (h *uploadQueryHandler) ListMyUploads(w http.ResponseWriter, _ *http.Request, p gen.ListMyUploadsParams) {
|
||||
h.statuses = *p.Status
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
}
|
||||
|
||||
func (h *uploadQueryHandler) ListUploads(w http.ResponseWriter, _ *http.Request, p gen.ListUploadsParams) {
|
||||
h.statuses = *p.Status
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
}
|
||||
|
||||
func TestUploadFiltersBindCommaSeparatedStatuses(t *testing.T) {
|
||||
for _, path := range []string{"/api/v1/uploads/mine", "/api/v1/admin/uploads"} {
|
||||
t.Run(path, func(t *testing.T) {
|
||||
h := &uploadQueryHandler{}
|
||||
rec := httptest.NewRecorder()
|
||||
gen.Handler(h).ServeHTTP(rec, httptest.NewRequest(http.MethodGet, path+"?status=pending_review,imported,expired&limit=50", nil))
|
||||
require.Equal(t, http.StatusNoContent, rec.Code, rec.Body.String())
|
||||
require.Equal(t, []gen.UploadStatus{gen.UploadStatusPendingReview, gen.UploadStatusImported, gen.UploadStatusExpired}, h.statuses)
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user