Return 400 error if limit_after is zero (#15049)

Этот коммит содержится в:
Claudio Costa
2020-07-20 10:08:52 +02:00
коммит произвёл GitHub
родитель aae3b9650f
Коммит 484e813dca
4 изменённых файлов: 30 добавлений и 1 удалений

Просмотреть файл

@@ -5,6 +5,7 @@ package storetest
import (
"fmt"
"net/http"
"sort"
"strings"
"testing"
@@ -893,6 +894,18 @@ func testPostStoreGetPostsBeforeAfter(t *testing.T, ss store.Store) {
time.Sleep(time.Millisecond)
}
t.Run("should return error if negative Page/PerPage options are passed", func(t *testing.T) {
postList, err := ss.Post().GetPostsAfter(model.GetPostsOptions{ChannelId: channelId, PostId: posts[0].Id, Page: 0, PerPage: -1})
assert.Nil(t, postList)
assert.Error(t, err)
assert.Equal(t, http.StatusBadRequest, err.StatusCode)
postList, err = ss.Post().GetPostsAfter(model.GetPostsOptions{ChannelId: channelId, PostId: posts[0].Id, Page: -1, PerPage: 10})
assert.Nil(t, postList)
assert.Error(t, err)
assert.Equal(t, http.StatusBadRequest, err.StatusCode)
})
t.Run("should not return anything before the first post", func(t *testing.T) {
postList, err := ss.Post().GetPostsBefore(model.GetPostsOptions{ChannelId: channelId, PostId: posts[0].Id, Page: 0, PerPage: 10})
assert.Nil(t, err)