Migration of PostStore Part 2 (#15181)
* Starting migration * Lint: remove unnecessary use of sprintf * Fix i18n * Some suggestions * Fix store layers Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
d85cec1a4e
Коммит
1ab06ffa7c
@@ -169,7 +169,7 @@ func (_m *PostStore) GetEtag(channelId string, allowFromCache bool) string {
|
||||
}
|
||||
|
||||
// GetFlaggedPosts provides a mock function with given fields: userId, offset, limit
|
||||
func (_m *PostStore) GetFlaggedPosts(userId string, offset int, limit int) (*model.PostList, *model.AppError) {
|
||||
func (_m *PostStore) GetFlaggedPosts(userId string, offset int, limit int) (*model.PostList, error) {
|
||||
ret := _m.Called(userId, offset, limit)
|
||||
|
||||
var r0 *model.PostList
|
||||
@@ -181,20 +181,18 @@ func (_m *PostStore) GetFlaggedPosts(userId string, offset int, limit int) (*mod
|
||||
}
|
||||
}
|
||||
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func(string, int, int) *model.AppError); ok {
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(string, int, int) error); ok {
|
||||
r1 = rf(userId, offset, limit)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetFlaggedPostsForChannel provides a mock function with given fields: userId, channelId, offset, limit
|
||||
func (_m *PostStore) GetFlaggedPostsForChannel(userId string, channelId string, offset int, limit int) (*model.PostList, *model.AppError) {
|
||||
func (_m *PostStore) GetFlaggedPostsForChannel(userId string, channelId string, offset int, limit int) (*model.PostList, error) {
|
||||
ret := _m.Called(userId, channelId, offset, limit)
|
||||
|
||||
var r0 *model.PostList
|
||||
@@ -206,20 +204,18 @@ func (_m *PostStore) GetFlaggedPostsForChannel(userId string, channelId string,
|
||||
}
|
||||
}
|
||||
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func(string, string, int, int) *model.AppError); ok {
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(string, string, int, int) error); ok {
|
||||
r1 = rf(userId, channelId, offset, limit)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetFlaggedPostsForTeam provides a mock function with given fields: userId, teamId, offset, limit
|
||||
func (_m *PostStore) GetFlaggedPostsForTeam(userId string, teamId string, offset int, limit int) (*model.PostList, *model.AppError) {
|
||||
func (_m *PostStore) GetFlaggedPostsForTeam(userId string, teamId string, offset int, limit int) (*model.PostList, error) {
|
||||
ret := _m.Called(userId, teamId, offset, limit)
|
||||
|
||||
var r0 *model.PostList
|
||||
@@ -231,13 +227,11 @@ func (_m *PostStore) GetFlaggedPostsForTeam(userId string, teamId string, offset
|
||||
}
|
||||
}
|
||||
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func(string, string, int, int) *model.AppError); ok {
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(string, string, int, int) error); ok {
|
||||
r1 = rf(userId, teamId, offset, limit)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
@@ -331,7 +325,7 @@ func (_m *PostStore) GetParentsForExportAfter(limit int, afterId string) ([]*mod
|
||||
}
|
||||
|
||||
// GetPostAfterTime provides a mock function with given fields: channelId, time
|
||||
func (_m *PostStore) GetPostAfterTime(channelId string, time int64) (*model.Post, *model.AppError) {
|
||||
func (_m *PostStore) GetPostAfterTime(channelId string, time int64) (*model.Post, error) {
|
||||
ret := _m.Called(channelId, time)
|
||||
|
||||
var r0 *model.Post
|
||||
@@ -343,20 +337,18 @@ func (_m *PostStore) GetPostAfterTime(channelId string, time int64) (*model.Post
|
||||
}
|
||||
}
|
||||
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func(string, int64) *model.AppError); ok {
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(string, int64) error); ok {
|
||||
r1 = rf(channelId, time)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetPostIdAfterTime provides a mock function with given fields: channelId, time
|
||||
func (_m *PostStore) GetPostIdAfterTime(channelId string, time int64) (string, *model.AppError) {
|
||||
func (_m *PostStore) GetPostIdAfterTime(channelId string, time int64) (string, error) {
|
||||
ret := _m.Called(channelId, time)
|
||||
|
||||
var r0 string
|
||||
@@ -366,20 +358,18 @@ func (_m *PostStore) GetPostIdAfterTime(channelId string, time int64) (string, *
|
||||
r0 = ret.Get(0).(string)
|
||||
}
|
||||
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func(string, int64) *model.AppError); ok {
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(string, int64) error); ok {
|
||||
r1 = rf(channelId, time)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetPostIdBeforeTime provides a mock function with given fields: channelId, time
|
||||
func (_m *PostStore) GetPostIdBeforeTime(channelId string, time int64) (string, *model.AppError) {
|
||||
func (_m *PostStore) GetPostIdBeforeTime(channelId string, time int64) (string, error) {
|
||||
ret := _m.Called(channelId, time)
|
||||
|
||||
var r0 string
|
||||
@@ -389,13 +379,11 @@ func (_m *PostStore) GetPostIdBeforeTime(channelId string, time int64) (string,
|
||||
r0 = ret.Get(0).(string)
|
||||
}
|
||||
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func(string, int64) *model.AppError); ok {
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(string, int64) error); ok {
|
||||
r1 = rf(channelId, time)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
@@ -427,7 +415,7 @@ func (_m *PostStore) GetPosts(options model.GetPostsOptions, allowFromCache bool
|
||||
}
|
||||
|
||||
// GetPostsAfter provides a mock function with given fields: options
|
||||
func (_m *PostStore) GetPostsAfter(options model.GetPostsOptions) (*model.PostList, *model.AppError) {
|
||||
func (_m *PostStore) GetPostsAfter(options model.GetPostsOptions) (*model.PostList, error) {
|
||||
ret := _m.Called(options)
|
||||
|
||||
var r0 *model.PostList
|
||||
@@ -439,13 +427,11 @@ func (_m *PostStore) GetPostsAfter(options model.GetPostsOptions) (*model.PostLi
|
||||
}
|
||||
}
|
||||
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func(model.GetPostsOptions) *model.AppError); ok {
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(model.GetPostsOptions) error); ok {
|
||||
r1 = rf(options)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
@@ -477,7 +463,7 @@ func (_m *PostStore) GetPostsBatchForIndexing(startTime int64, endTime int64, li
|
||||
}
|
||||
|
||||
// GetPostsBefore provides a mock function with given fields: options
|
||||
func (_m *PostStore) GetPostsBefore(options model.GetPostsOptions) (*model.PostList, *model.AppError) {
|
||||
func (_m *PostStore) GetPostsBefore(options model.GetPostsOptions) (*model.PostList, error) {
|
||||
ret := _m.Called(options)
|
||||
|
||||
var r0 *model.PostList
|
||||
@@ -489,13 +475,11 @@ func (_m *PostStore) GetPostsBefore(options model.GetPostsOptions) (*model.PostL
|
||||
}
|
||||
}
|
||||
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func(model.GetPostsOptions) *model.AppError); ok {
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(model.GetPostsOptions) error); ok {
|
||||
r1 = rf(options)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
@@ -552,7 +536,7 @@ func (_m *PostStore) GetPostsCreatedAt(channelId string, time int64) ([]*model.P
|
||||
}
|
||||
|
||||
// GetPostsSince provides a mock function with given fields: options, allowFromCache
|
||||
func (_m *PostStore) GetPostsSince(options model.GetPostsSinceOptions, allowFromCache bool) (*model.PostList, *model.AppError) {
|
||||
func (_m *PostStore) GetPostsSince(options model.GetPostsSinceOptions, allowFromCache bool) (*model.PostList, error) {
|
||||
ret := _m.Called(options, allowFromCache)
|
||||
|
||||
var r0 *model.PostList
|
||||
@@ -564,13 +548,11 @@ func (_m *PostStore) GetPostsSince(options model.GetPostsSinceOptions, allowFrom
|
||||
}
|
||||
}
|
||||
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func(model.GetPostsSinceOptions, bool) *model.AppError); ok {
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(model.GetPostsSinceOptions, bool) error); ok {
|
||||
r1 = rf(options, allowFromCache)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
|
||||
@@ -5,7 +5,6 @@ package storetest
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"sort"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -898,12 +897,12 @@ func testPostStoreGetPostsBeforeAfter(t *testing.T, ss store.Store) {
|
||||
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)
|
||||
assert.IsType(t, &store.ErrInvalidInput{}, err)
|
||||
|
||||
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)
|
||||
assert.IsType(t, &store.ErrInvalidInput{}, err)
|
||||
})
|
||||
|
||||
t.Run("should not return anything before the first post", func(t *testing.T) {
|
||||
|
||||
Ссылка в новой задаче
Block a user