коммит произвёл
GitHub
родитель
a251510717
Коммит
c6f80dfe0a
@@ -123,13 +123,13 @@ func (_m *PostStore) DeleteOrphanedRows(limit int) (int64, error) {
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// Get provides a mock function with given fields: ctx, id, opts, userID
|
||||
func (_m *PostStore) Get(ctx context.Context, id string, opts model.GetPostsOptions, userID string) (*model.PostList, error) {
|
||||
ret := _m.Called(ctx, id, opts, userID)
|
||||
// Get provides a mock function with given fields: ctx, id, opts, userID, sanitizeOptions
|
||||
func (_m *PostStore) Get(ctx context.Context, id string, opts model.GetPostsOptions, userID string, sanitizeOptions map[string]bool) (*model.PostList, error) {
|
||||
ret := _m.Called(ctx, id, opts, userID, sanitizeOptions)
|
||||
|
||||
var r0 *model.PostList
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string, model.GetPostsOptions, string) *model.PostList); ok {
|
||||
r0 = rf(ctx, id, opts, userID)
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string, model.GetPostsOptions, string, map[string]bool) *model.PostList); ok {
|
||||
r0 = rf(ctx, id, opts, userID, sanitizeOptions)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*model.PostList)
|
||||
@@ -137,8 +137,8 @@ func (_m *PostStore) Get(ctx context.Context, id string, opts model.GetPostsOpti
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(context.Context, string, model.GetPostsOptions, string) error); ok {
|
||||
r1 = rf(ctx, id, opts, userID)
|
||||
if rf, ok := ret.Get(1).(func(context.Context, string, model.GetPostsOptions, string, map[string]bool) error); ok {
|
||||
r1 = rf(ctx, id, opts, userID, sanitizeOptions)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
@@ -419,13 +419,13 @@ func (_m *PostStore) GetPostIdBeforeTime(channelID string, time int64, collapsed
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetPosts provides a mock function with given fields: options, allowFromCache
|
||||
func (_m *PostStore) GetPosts(options model.GetPostsOptions, allowFromCache bool) (*model.PostList, error) {
|
||||
ret := _m.Called(options, allowFromCache)
|
||||
// GetPosts provides a mock function with given fields: options, allowFromCache, sanitizeOptions
|
||||
func (_m *PostStore) GetPosts(options model.GetPostsOptions, allowFromCache bool, sanitizeOptions map[string]bool) (*model.PostList, error) {
|
||||
ret := _m.Called(options, allowFromCache, sanitizeOptions)
|
||||
|
||||
var r0 *model.PostList
|
||||
if rf, ok := ret.Get(0).(func(model.GetPostsOptions, bool) *model.PostList); ok {
|
||||
r0 = rf(options, allowFromCache)
|
||||
if rf, ok := ret.Get(0).(func(model.GetPostsOptions, bool, map[string]bool) *model.PostList); ok {
|
||||
r0 = rf(options, allowFromCache, sanitizeOptions)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*model.PostList)
|
||||
@@ -433,8 +433,8 @@ func (_m *PostStore) GetPosts(options model.GetPostsOptions, allowFromCache bool
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(model.GetPostsOptions, bool) error); ok {
|
||||
r1 = rf(options, allowFromCache)
|
||||
if rf, ok := ret.Get(1).(func(model.GetPostsOptions, bool, map[string]bool) error); ok {
|
||||
r1 = rf(options, allowFromCache, sanitizeOptions)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
@@ -442,13 +442,13 @@ func (_m *PostStore) GetPosts(options model.GetPostsOptions, allowFromCache bool
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetPostsAfter provides a mock function with given fields: options
|
||||
func (_m *PostStore) GetPostsAfter(options model.GetPostsOptions) (*model.PostList, error) {
|
||||
ret := _m.Called(options)
|
||||
// GetPostsAfter provides a mock function with given fields: options, sanitizeOptions
|
||||
func (_m *PostStore) GetPostsAfter(options model.GetPostsOptions, sanitizeOptions map[string]bool) (*model.PostList, error) {
|
||||
ret := _m.Called(options, sanitizeOptions)
|
||||
|
||||
var r0 *model.PostList
|
||||
if rf, ok := ret.Get(0).(func(model.GetPostsOptions) *model.PostList); ok {
|
||||
r0 = rf(options)
|
||||
if rf, ok := ret.Get(0).(func(model.GetPostsOptions, map[string]bool) *model.PostList); ok {
|
||||
r0 = rf(options, sanitizeOptions)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*model.PostList)
|
||||
@@ -456,8 +456,8 @@ func (_m *PostStore) GetPostsAfter(options model.GetPostsOptions) (*model.PostLi
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(model.GetPostsOptions) error); ok {
|
||||
r1 = rf(options)
|
||||
if rf, ok := ret.Get(1).(func(model.GetPostsOptions, map[string]bool) error); ok {
|
||||
r1 = rf(options, sanitizeOptions)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
@@ -488,13 +488,13 @@ func (_m *PostStore) GetPostsBatchForIndexing(startTime int64, startPostID strin
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetPostsBefore provides a mock function with given fields: options
|
||||
func (_m *PostStore) GetPostsBefore(options model.GetPostsOptions) (*model.PostList, error) {
|
||||
ret := _m.Called(options)
|
||||
// GetPostsBefore provides a mock function with given fields: options, sanitizeOptions
|
||||
func (_m *PostStore) GetPostsBefore(options model.GetPostsOptions, sanitizeOptions map[string]bool) (*model.PostList, error) {
|
||||
ret := _m.Called(options, sanitizeOptions)
|
||||
|
||||
var r0 *model.PostList
|
||||
if rf, ok := ret.Get(0).(func(model.GetPostsOptions) *model.PostList); ok {
|
||||
r0 = rf(options)
|
||||
if rf, ok := ret.Get(0).(func(model.GetPostsOptions, map[string]bool) *model.PostList); ok {
|
||||
r0 = rf(options, sanitizeOptions)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*model.PostList)
|
||||
@@ -502,8 +502,8 @@ func (_m *PostStore) GetPostsBefore(options model.GetPostsOptions) (*model.PostL
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(model.GetPostsOptions) error); ok {
|
||||
r1 = rf(options)
|
||||
if rf, ok := ret.Get(1).(func(model.GetPostsOptions, map[string]bool) error); ok {
|
||||
r1 = rf(options, sanitizeOptions)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
@@ -557,13 +557,13 @@ func (_m *PostStore) GetPostsCreatedAt(channelID string, time int64) ([]*model.P
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetPostsSince provides a mock function with given fields: options, allowFromCache
|
||||
func (_m *PostStore) GetPostsSince(options model.GetPostsSinceOptions, allowFromCache bool) (*model.PostList, error) {
|
||||
ret := _m.Called(options, allowFromCache)
|
||||
// GetPostsSince provides a mock function with given fields: options, allowFromCache, sanitizeOptions
|
||||
func (_m *PostStore) GetPostsSince(options model.GetPostsSinceOptions, allowFromCache bool, sanitizeOptions map[string]bool) (*model.PostList, error) {
|
||||
ret := _m.Called(options, allowFromCache, sanitizeOptions)
|
||||
|
||||
var r0 *model.PostList
|
||||
if rf, ok := ret.Get(0).(func(model.GetPostsSinceOptions, bool) *model.PostList); ok {
|
||||
r0 = rf(options, allowFromCache)
|
||||
if rf, ok := ret.Get(0).(func(model.GetPostsSinceOptions, bool, map[string]bool) *model.PostList); ok {
|
||||
r0 = rf(options, allowFromCache, sanitizeOptions)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*model.PostList)
|
||||
@@ -571,8 +571,8 @@ func (_m *PostStore) GetPostsSince(options model.GetPostsSinceOptions, allowFrom
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(model.GetPostsSinceOptions, bool) error); ok {
|
||||
r1 = rf(options, allowFromCache)
|
||||
if rf, ok := ret.Get(1).(func(model.GetPostsSinceOptions, bool, map[string]bool) error); ok {
|
||||
r1 = rf(options, allowFromCache, sanitizeOptions)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
@@ -492,14 +492,14 @@ func testPostStoreGet(t *testing.T, ss store.Store) {
|
||||
etag2 := ss.Post().GetEtag(o1.ChannelId, false, false)
|
||||
require.Equal(t, 0, strings.Index(etag2, fmt.Sprintf("%v.%v", model.CurrentVersion, o1.UpdateAt)), "Invalid Etag")
|
||||
|
||||
r1, err := ss.Post().Get(context.Background(), o1.Id, model.GetPostsOptions{}, "")
|
||||
r1, err := ss.Post().Get(context.Background(), o1.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, r1.Posts[o1.Id].CreateAt, o1.CreateAt, "invalid returned post")
|
||||
|
||||
_, err = ss.Post().Get(context.Background(), "123", model.GetPostsOptions{}, "")
|
||||
_, err = ss.Post().Get(context.Background(), "123", model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.Error(t, err, "Missing id should have failed")
|
||||
|
||||
_, err = ss.Post().Get(context.Background(), "", model.GetPostsOptions{}, "")
|
||||
_, err = ss.Post().Get(context.Background(), "", model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.Error(t, err, "should fail for blank post ids")
|
||||
}
|
||||
|
||||
@@ -519,7 +519,7 @@ func testPostStoreGetForThread(t *testing.T, ss store.Store) {
|
||||
opts := model.GetPostsOptions{
|
||||
CollapsedThreads: true,
|
||||
}
|
||||
r1, err := ss.Post().Get(context.Background(), o1.Id, opts, o1.UserId)
|
||||
r1, err := ss.Post().Get(context.Background(), o1.Id, opts, o1.UserId, map[string]bool{})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, r1.Posts[o1.Id].CreateAt, o1.CreateAt, "invalid returned post")
|
||||
require.True(t, *r1.Posts[o1.Id].IsFollowing)
|
||||
@@ -540,7 +540,7 @@ func testPostStoreGetForThread(t *testing.T, ss store.Store) {
|
||||
opts := model.GetPostsOptions{
|
||||
CollapsedThreads: true,
|
||||
}
|
||||
r1, err := ss.Post().Get(context.Background(), o1.Id, opts, o1.UserId)
|
||||
r1, err := ss.Post().Get(context.Background(), o1.Id, opts, o1.UserId, map[string]bool{})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, r1.Posts[o1.Id].CreateAt, o1.CreateAt, "invalid returned post")
|
||||
require.False(t, *r1.Posts[o1.Id].IsFollowing)
|
||||
@@ -556,7 +556,7 @@ func testPostStoreGetForThread(t *testing.T, ss store.Store) {
|
||||
opts := model.GetPostsOptions{
|
||||
CollapsedThreads: true,
|
||||
}
|
||||
r1, err := ss.Post().Get(context.Background(), o1.Id, opts, o1.UserId)
|
||||
r1, err := ss.Post().Get(context.Background(), o1.Id, opts, o1.UserId, map[string]bool{})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, r1.Posts[o1.Id].CreateAt, o1.CreateAt, "invalid returned post")
|
||||
require.Nil(t, r1.Posts[o1.Id].IsFollowing)
|
||||
@@ -579,7 +579,7 @@ func testPostStoreGetForThread(t *testing.T, ss store.Store) {
|
||||
PerPage: 2,
|
||||
Direction: "down",
|
||||
}
|
||||
r1, err := ss.Post().Get(context.Background(), o1.Id, opts, o1.UserId)
|
||||
r1, err := ss.Post().Get(context.Background(), o1.Id, opts, o1.UserId, map[string]bool{})
|
||||
require.NoError(t, err)
|
||||
assert.Len(t, r1.Order, 3) // including the root post
|
||||
assert.True(t, r1.HasNext)
|
||||
@@ -594,7 +594,7 @@ func testPostStoreGetForThread(t *testing.T, ss store.Store) {
|
||||
FromPost: lastPostID,
|
||||
FromCreateAt: lastPostCreateAt,
|
||||
}
|
||||
r1, err = ss.Post().Get(context.Background(), o1.Id, opts, o1.UserId)
|
||||
r1, err = ss.Post().Get(context.Background(), o1.Id, opts, o1.UserId, map[string]bool{})
|
||||
require.NoError(t, err)
|
||||
assert.Len(t, r1.Order, 3) // including the root post
|
||||
assert.GreaterOrEqual(t, r1.Posts[r1.Order[len(r1.Order)-1]].CreateAt, lastPostCreateAt)
|
||||
@@ -609,7 +609,7 @@ func testPostStoreGetForThread(t *testing.T, ss store.Store) {
|
||||
FromPost: r1.Order[1],
|
||||
FromCreateAt: firstPostCreateAt,
|
||||
}
|
||||
r1, err = ss.Post().Get(context.Background(), o1.Id, opts, o1.UserId)
|
||||
r1, err = ss.Post().Get(context.Background(), o1.Id, opts, o1.UserId, map[string]bool{})
|
||||
require.NoError(t, err)
|
||||
assert.Len(t, r1.Order, 3) // including the root post
|
||||
assert.LessOrEqual(t, r1.Posts[r1.Order[1]].CreateAt, firstPostCreateAt)
|
||||
@@ -623,7 +623,7 @@ func testPostStoreGetForThread(t *testing.T, ss store.Store) {
|
||||
FromCreateAt: m1.CreateAt,
|
||||
SkipFetchThreads: false,
|
||||
}
|
||||
r1, err = ss.Post().Get(context.Background(), o1.Id, opts, o1.UserId)
|
||||
r1, err = ss.Post().Get(context.Background(), o1.Id, opts, o1.UserId, map[string]bool{})
|
||||
require.NoError(t, err)
|
||||
assert.Len(t, r1.Order, 2) // including the root post
|
||||
assert.LessOrEqual(t, r1.Posts[r1.Order[1]].CreateAt, m1.CreateAt)
|
||||
@@ -636,7 +636,7 @@ func testPostStoreGetForThread(t *testing.T, ss store.Store) {
|
||||
Direction: "down",
|
||||
SkipFetchThreads: false,
|
||||
}
|
||||
r1, err = ss.Post().Get(context.Background(), o1.Id, opts, o1.UserId)
|
||||
r1, err = ss.Post().Get(context.Background(), o1.Id, opts, o1.UserId, map[string]bool{})
|
||||
require.NoError(t, err)
|
||||
assert.Len(t, r1.Order, 3) // including the root post
|
||||
assert.True(t, r1.HasNext)
|
||||
@@ -652,7 +652,7 @@ func testPostStoreGetForThread(t *testing.T, ss store.Store) {
|
||||
FromCreateAt: lastPostCreateAt,
|
||||
SkipFetchThreads: false,
|
||||
}
|
||||
r1, err = ss.Post().Get(context.Background(), o1.Id, opts, o1.UserId)
|
||||
r1, err = ss.Post().Get(context.Background(), o1.Id, opts, o1.UserId, map[string]bool{})
|
||||
require.NoError(t, err)
|
||||
assert.Len(t, r1.Order, 4) // including the root post
|
||||
assert.GreaterOrEqual(t, r1.Posts[r1.Order[len(r1.Order)-1]].CreateAt, lastPostCreateAt)
|
||||
@@ -668,7 +668,7 @@ func testPostStoreGetForThread(t *testing.T, ss store.Store) {
|
||||
FromCreateAt: firstPostCreateAt,
|
||||
SkipFetchThreads: false,
|
||||
}
|
||||
r1, err = ss.Post().Get(context.Background(), o1.Id, opts, o1.UserId)
|
||||
r1, err = ss.Post().Get(context.Background(), o1.Id, opts, o1.UserId, map[string]bool{})
|
||||
require.NoError(t, err)
|
||||
assert.Len(t, r1.Order, 3) // including the root post
|
||||
assert.LessOrEqual(t, r1.Posts[r1.Order[1]].CreateAt, firstPostCreateAt)
|
||||
@@ -682,7 +682,7 @@ func testPostStoreGetForThread(t *testing.T, ss store.Store) {
|
||||
FromCreateAt: m1.CreateAt,
|
||||
SkipFetchThreads: false,
|
||||
}
|
||||
r1, err = ss.Post().Get(context.Background(), o1.Id, opts, o1.UserId)
|
||||
r1, err = ss.Post().Get(context.Background(), o1.Id, opts, o1.UserId, map[string]bool{})
|
||||
require.NoError(t, err)
|
||||
assert.Len(t, r1.Order, 2) // including the root post
|
||||
assert.GreaterOrEqual(t, r1.Posts[r1.Order[1]].CreateAt, m1.CreateAt)
|
||||
@@ -772,15 +772,15 @@ func testPostStoreUpdate(t *testing.T, ss store.Store) {
|
||||
o3, err = ss.Post().Save(o3)
|
||||
require.NoError(t, err)
|
||||
|
||||
r1, err := ss.Post().Get(context.Background(), o1.Id, model.GetPostsOptions{}, "")
|
||||
r1, err := ss.Post().Get(context.Background(), o1.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.NoError(t, err)
|
||||
ro1 := r1.Posts[o1.Id]
|
||||
|
||||
r2, err := ss.Post().Get(context.Background(), o1.Id, model.GetPostsOptions{}, "")
|
||||
r2, err := ss.Post().Get(context.Background(), o1.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.NoError(t, err)
|
||||
ro2 := r2.Posts[o2.Id]
|
||||
|
||||
r3, err := ss.Post().Get(context.Background(), o3.Id, model.GetPostsOptions{}, "")
|
||||
r3, err := ss.Post().Get(context.Background(), o3.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.NoError(t, err)
|
||||
ro3 := r3.Posts[o3.Id]
|
||||
|
||||
@@ -791,7 +791,7 @@ func testPostStoreUpdate(t *testing.T, ss store.Store) {
|
||||
_, err = ss.Post().Update(o1a, ro1)
|
||||
require.NoError(t, err)
|
||||
|
||||
r1, err = ss.Post().Get(context.Background(), o1.Id, model.GetPostsOptions{}, "")
|
||||
r1, err = ss.Post().Get(context.Background(), o1.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.NoError(t, err)
|
||||
|
||||
ro1a := r1.Posts[o1.Id]
|
||||
@@ -802,7 +802,7 @@ func testPostStoreUpdate(t *testing.T, ss store.Store) {
|
||||
_, err = ss.Post().Update(o2a, ro2)
|
||||
require.NoError(t, err)
|
||||
|
||||
r2, err = ss.Post().Get(context.Background(), o1.Id, model.GetPostsOptions{}, "")
|
||||
r2, err = ss.Post().Get(context.Background(), o1.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.NoError(t, err)
|
||||
ro2a := r2.Posts[o2.Id]
|
||||
|
||||
@@ -813,7 +813,7 @@ func testPostStoreUpdate(t *testing.T, ss store.Store) {
|
||||
_, err = ss.Post().Update(o3a, ro3)
|
||||
require.NoError(t, err)
|
||||
|
||||
r3, err = ss.Post().Get(context.Background(), o3.Id, model.GetPostsOptions{}, "")
|
||||
r3, err = ss.Post().Get(context.Background(), o3.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.NoError(t, err)
|
||||
ro3a := r3.Posts[o3.Id]
|
||||
|
||||
@@ -829,7 +829,7 @@ func testPostStoreUpdate(t *testing.T, ss store.Store) {
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
r4, err := ss.Post().Get(context.Background(), o4.Id, model.GetPostsOptions{}, "")
|
||||
r4, err := ss.Post().Get(context.Background(), o4.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.NoError(t, err)
|
||||
ro4 := r4.Posts[o4.Id]
|
||||
|
||||
@@ -839,7 +839,7 @@ func testPostStoreUpdate(t *testing.T, ss store.Store) {
|
||||
_, err = ss.Post().Update(o4a, ro4)
|
||||
require.NoError(t, err)
|
||||
|
||||
r4, err = ss.Post().Get(context.Background(), o4.Id, model.GetPostsOptions{}, "")
|
||||
r4, err = ss.Post().Get(context.Background(), o4.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.NoError(t, err)
|
||||
|
||||
ro4a := r4.Posts[o4.Id]
|
||||
@@ -862,7 +862,7 @@ func testPostStoreDelete(t *testing.T, ss store.Store) {
|
||||
require.Equal(t, 0, strings.Index(etag1, model.CurrentVersion+"."), "Invalid Etag")
|
||||
|
||||
// Verify the created post.
|
||||
r1, err := ss.Post().Get(context.Background(), rootPost.Id, model.GetPostsOptions{}, "")
|
||||
r1, err := ss.Post().Get(context.Background(), rootPost.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, r1.Posts[rootPost.Id])
|
||||
require.Equal(t, rootPost, r1.Posts[rootPost.Id])
|
||||
@@ -879,7 +879,7 @@ func testPostStoreDelete(t *testing.T, ss store.Store) {
|
||||
assert.Equal(t, deleteByID, posts[0].GetProp(model.PostPropsDeleteBy), "unexpected Props[model.PostPropsDeleteBy]")
|
||||
|
||||
// Verify that the post is no longer fetched by default.
|
||||
_, err = ss.Post().Get(context.Background(), rootPost.Id, model.GetPostsOptions{}, "")
|
||||
_, err = ss.Post().Get(context.Background(), rootPost.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.Error(t, err, "fetching deleted post should have failed")
|
||||
require.IsType(t, &store.ErrNotFound{}, err)
|
||||
|
||||
@@ -911,12 +911,12 @@ func testPostStoreDelete(t *testing.T, ss store.Store) {
|
||||
require.NoError(t, err)
|
||||
|
||||
// Verify the root post deleted
|
||||
_, err = ss.Post().Get(context.Background(), rootPost.Id, model.GetPostsOptions{}, "")
|
||||
_, err = ss.Post().Get(context.Background(), rootPost.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.Error(t, err, "Deleted id should have failed")
|
||||
require.IsType(t, &store.ErrNotFound{}, err)
|
||||
|
||||
// Verify the reply post deleted
|
||||
_, err = ss.Post().Get(context.Background(), replyPost.Id, model.GetPostsOptions{}, "")
|
||||
_, err = ss.Post().Get(context.Background(), replyPost.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.Error(t, err, "Deleted id should have failed")
|
||||
require.IsType(t, &store.ErrNotFound{}, err)
|
||||
})
|
||||
@@ -961,17 +961,17 @@ func testPostStoreDelete(t *testing.T, ss store.Store) {
|
||||
require.NoError(t, err)
|
||||
|
||||
// Verify the root post and replies deleted
|
||||
_, err = ss.Post().Get(context.Background(), rootPost1.Id, model.GetPostsOptions{}, "")
|
||||
_, err = ss.Post().Get(context.Background(), rootPost1.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.Error(t, err, "Deleted id should have failed")
|
||||
|
||||
_, err = ss.Post().Get(context.Background(), replyPost1.Id, model.GetPostsOptions{}, "")
|
||||
_, err = ss.Post().Get(context.Background(), replyPost1.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.Error(t, err, "Deleted id should have failed")
|
||||
|
||||
_, err = ss.Post().Get(context.Background(), replyPost2.Id, model.GetPostsOptions{}, "")
|
||||
_, err = ss.Post().Get(context.Background(), replyPost2.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.Error(t, err, "Deleted id should have failed")
|
||||
|
||||
// Verify other root posts remain undeleted.
|
||||
_, err = ss.Post().Get(context.Background(), rootPost2.Id, model.GetPostsOptions{}, "")
|
||||
_, err = ss.Post().Get(context.Background(), rootPost2.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.NoError(t, err)
|
||||
})
|
||||
}
|
||||
@@ -1038,10 +1038,10 @@ func testPostStorePermDelete1Level(t *testing.T, ss store.Store) {
|
||||
require.EqualValues(t, 0, thread.ReplyCount)
|
||||
require.EqualValues(t, model.StringArray{}, thread.Participants)
|
||||
|
||||
_, err = ss.Post().Get(context.Background(), o1.Id, model.GetPostsOptions{}, "")
|
||||
_, err = ss.Post().Get(context.Background(), o1.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.NoError(t, err, "Deleted id shouldn't have failed")
|
||||
|
||||
_, err = ss.Post().Get(context.Background(), o2.Id, model.GetPostsOptions{}, "")
|
||||
_, err = ss.Post().Get(context.Background(), o2.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.Error(t, err, "Deleted id should have failed")
|
||||
|
||||
thread, err = ss.Thread().Get(o5.Id)
|
||||
@@ -1055,16 +1055,16 @@ func testPostStorePermDelete1Level(t *testing.T, ss store.Store) {
|
||||
require.NoError(t, err)
|
||||
require.Nil(t, thread)
|
||||
|
||||
_, err = ss.Post().Get(context.Background(), o3.Id, model.GetPostsOptions{}, "")
|
||||
_, err = ss.Post().Get(context.Background(), o3.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.Error(t, err, "Deleted id should have failed")
|
||||
|
||||
_, err = ss.Post().Get(context.Background(), o4.Id, model.GetPostsOptions{}, "")
|
||||
_, err = ss.Post().Get(context.Background(), o4.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.Error(t, err, "Deleted id should have failed")
|
||||
|
||||
_, err = ss.Post().Get(context.Background(), o5.Id, model.GetPostsOptions{}, "")
|
||||
_, err = ss.Post().Get(context.Background(), o5.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.Error(t, err, "Deleted id should have failed")
|
||||
|
||||
_, err = ss.Post().Get(context.Background(), o6.Id, model.GetPostsOptions{}, "")
|
||||
_, err = ss.Post().Get(context.Background(), o6.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.Error(t, err, "Deleted id should have failed")
|
||||
}
|
||||
|
||||
@@ -1094,13 +1094,13 @@ func testPostStorePermDelete1Level2(t *testing.T, ss store.Store) {
|
||||
err2 := ss.Post().PermanentDeleteByUser(o1.UserId)
|
||||
require.NoError(t, err2)
|
||||
|
||||
_, err = ss.Post().Get(context.Background(), o1.Id, model.GetPostsOptions{}, "")
|
||||
_, err = ss.Post().Get(context.Background(), o1.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.Error(t, err, "Deleted id should have failed")
|
||||
|
||||
_, err = ss.Post().Get(context.Background(), o2.Id, model.GetPostsOptions{}, "")
|
||||
_, err = ss.Post().Get(context.Background(), o2.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.Error(t, err, "Deleted id should have failed")
|
||||
|
||||
_, err = ss.Post().Get(context.Background(), o3.Id, model.GetPostsOptions{}, "")
|
||||
_, err = ss.Post().Get(context.Background(), o3.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.NoError(t, err, "Deleted id should have failed")
|
||||
}
|
||||
|
||||
@@ -1128,7 +1128,7 @@ func testPostStoreGetWithChildren(t *testing.T, ss store.Store) {
|
||||
o3, err = ss.Post().Save(o3)
|
||||
require.NoError(t, err)
|
||||
|
||||
pl, err := ss.Post().Get(context.Background(), o1.Id, model.GetPostsOptions{}, "")
|
||||
pl, err := ss.Post().Get(context.Background(), o1.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, pl.Posts, 3, "invalid returned post")
|
||||
@@ -1136,7 +1136,7 @@ func testPostStoreGetWithChildren(t *testing.T, ss store.Store) {
|
||||
dErr := ss.Post().Delete(o3.Id, model.GetMillis(), "")
|
||||
require.NoError(t, dErr)
|
||||
|
||||
pl, err = ss.Post().Get(context.Background(), o1.Id, model.GetPostsOptions{}, "")
|
||||
pl, err = ss.Post().Get(context.Background(), o1.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, pl.Posts, 2, "invalid returned post")
|
||||
@@ -1144,7 +1144,7 @@ func testPostStoreGetWithChildren(t *testing.T, ss store.Store) {
|
||||
dErr = ss.Post().Delete(o2.Id, model.GetMillis(), "")
|
||||
require.NoError(t, dErr)
|
||||
|
||||
pl, err = ss.Post().Get(context.Background(), o1.Id, model.GetPostsOptions{}, "")
|
||||
pl, err = ss.Post().Get(context.Background(), o1.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, pl.Posts, 1, "invalid returned post")
|
||||
@@ -1202,7 +1202,7 @@ func testPostStoreGetPostsWithDetails(t *testing.T, ss store.Store) {
|
||||
o5, err = ss.Post().Save(o5)
|
||||
require.NoError(t, err)
|
||||
|
||||
r1, err := ss.Post().GetPosts(model.GetPostsOptions{ChannelId: o1.ChannelId, Page: 0, PerPage: 4}, false)
|
||||
r1, err := ss.Post().GetPosts(model.GetPostsOptions{ChannelId: o1.ChannelId, Page: 0, PerPage: 4}, false, map[string]bool{})
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, r1.Order[0], o5.Id, "invalid order")
|
||||
@@ -1215,7 +1215,7 @@ func testPostStoreGetPostsWithDetails(t *testing.T, ss store.Store) {
|
||||
|
||||
require.Equal(t, r1.Posts[o1.Id].Message, o1.Message, "Missing parent")
|
||||
|
||||
r2, err := ss.Post().GetPosts(model.GetPostsOptions{ChannelId: o1.ChannelId, Page: 0, PerPage: 4}, false)
|
||||
r2, err := ss.Post().GetPosts(model.GetPostsOptions{ChannelId: o1.ChannelId, Page: 0, PerPage: 4}, false, map[string]bool{})
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, r2.Order[0], o5.Id, "invalid order")
|
||||
@@ -1229,7 +1229,7 @@ func testPostStoreGetPostsWithDetails(t *testing.T, ss store.Store) {
|
||||
require.Equal(t, r2.Posts[o1.Id].Message, o1.Message, "Missing parent")
|
||||
|
||||
// Run once to fill cache
|
||||
_, err = ss.Post().GetPosts(model.GetPostsOptions{ChannelId: o1.ChannelId, Page: 0, PerPage: 30}, false)
|
||||
_, err = ss.Post().GetPosts(model.GetPostsOptions{ChannelId: o1.ChannelId, Page: 0, PerPage: 30}, false, map[string]bool{})
|
||||
require.NoError(t, err)
|
||||
|
||||
o6 := &model.Post{}
|
||||
@@ -1239,7 +1239,7 @@ func testPostStoreGetPostsWithDetails(t *testing.T, ss store.Store) {
|
||||
_, err = ss.Post().Save(o6)
|
||||
require.NoError(t, err)
|
||||
|
||||
r3, err := ss.Post().GetPosts(model.GetPostsOptions{ChannelId: o1.ChannelId, Page: 0, PerPage: 30}, false)
|
||||
r3, err := ss.Post().GetPosts(model.GetPostsOptions{ChannelId: o1.ChannelId, Page: 0, PerPage: 30}, false, map[string]bool{})
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, 7, len(r3.Order))
|
||||
}
|
||||
@@ -1264,19 +1264,19 @@ func testPostStoreGetPostsBeforeAfter(t *testing.T, ss store.Store) {
|
||||
}
|
||||
|
||||
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})
|
||||
postList, err := ss.Post().GetPostsAfter(model.GetPostsOptions{ChannelId: channelId, PostId: posts[0].Id, Page: 0, PerPage: -1}, map[string]bool{})
|
||||
assert.Nil(t, postList)
|
||||
assert.Error(t, err)
|
||||
assert.IsType(t, &store.ErrInvalidInput{}, err)
|
||||
|
||||
postList, err = ss.Post().GetPostsAfter(model.GetPostsOptions{ChannelId: channelId, PostId: posts[0].Id, Page: -1, PerPage: 10})
|
||||
postList, err = ss.Post().GetPostsAfter(model.GetPostsOptions{ChannelId: channelId, PostId: posts[0].Id, Page: -1, PerPage: 10}, map[string]bool{})
|
||||
assert.Nil(t, postList)
|
||||
assert.Error(t, err)
|
||||
assert.IsType(t, &store.ErrInvalidInput{}, err)
|
||||
})
|
||||
|
||||
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})
|
||||
postList, err := ss.Post().GetPostsBefore(model.GetPostsOptions{ChannelId: channelId, PostId: posts[0].Id, Page: 0, PerPage: 10}, map[string]bool{})
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.Equal(t, []string{}, postList.Order)
|
||||
@@ -1284,7 +1284,7 @@ func testPostStoreGetPostsBeforeAfter(t *testing.T, ss store.Store) {
|
||||
})
|
||||
|
||||
t.Run("should return posts before a post", func(t *testing.T) {
|
||||
postList, err := ss.Post().GetPostsBefore(model.GetPostsOptions{ChannelId: channelId, PostId: posts[5].Id, Page: 0, PerPage: 10})
|
||||
postList, err := ss.Post().GetPostsBefore(model.GetPostsOptions{ChannelId: channelId, PostId: posts[5].Id, Page: 0, PerPage: 10}, map[string]bool{})
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.Equal(t, []string{posts[4].Id, posts[3].Id, posts[2].Id, posts[1].Id, posts[0].Id}, postList.Order)
|
||||
@@ -1298,7 +1298,7 @@ func testPostStoreGetPostsBeforeAfter(t *testing.T, ss store.Store) {
|
||||
})
|
||||
|
||||
t.Run("should limit posts before", func(t *testing.T) {
|
||||
postList, err := ss.Post().GetPostsBefore(model.GetPostsOptions{ChannelId: channelId, PostId: posts[5].Id, PerPage: 2})
|
||||
postList, err := ss.Post().GetPostsBefore(model.GetPostsOptions{ChannelId: channelId, PostId: posts[5].Id, PerPage: 2}, map[string]bool{})
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.Equal(t, []string{posts[4].Id, posts[3].Id}, postList.Order)
|
||||
@@ -1309,7 +1309,7 @@ func testPostStoreGetPostsBeforeAfter(t *testing.T, ss store.Store) {
|
||||
})
|
||||
|
||||
t.Run("should not return anything after the last post", func(t *testing.T) {
|
||||
postList, err := ss.Post().GetPostsAfter(model.GetPostsOptions{ChannelId: channelId, PostId: posts[len(posts)-1].Id, PerPage: 10})
|
||||
postList, err := ss.Post().GetPostsAfter(model.GetPostsOptions{ChannelId: channelId, PostId: posts[len(posts)-1].Id, PerPage: 10}, map[string]bool{})
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.Equal(t, []string{}, postList.Order)
|
||||
@@ -1317,7 +1317,7 @@ func testPostStoreGetPostsBeforeAfter(t *testing.T, ss store.Store) {
|
||||
})
|
||||
|
||||
t.Run("should return posts after a post", func(t *testing.T) {
|
||||
postList, err := ss.Post().GetPostsAfter(model.GetPostsOptions{ChannelId: channelId, PostId: posts[5].Id, PerPage: 10})
|
||||
postList, err := ss.Post().GetPostsAfter(model.GetPostsOptions{ChannelId: channelId, PostId: posts[5].Id, PerPage: 10}, map[string]bool{})
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.Equal(t, []string{posts[9].Id, posts[8].Id, posts[7].Id, posts[6].Id}, postList.Order)
|
||||
@@ -1330,7 +1330,7 @@ func testPostStoreGetPostsBeforeAfter(t *testing.T, ss store.Store) {
|
||||
})
|
||||
|
||||
t.Run("should limit posts after", func(t *testing.T) {
|
||||
postList, err := ss.Post().GetPostsAfter(model.GetPostsOptions{ChannelId: channelId, PostId: posts[5].Id, PerPage: 2})
|
||||
postList, err := ss.Post().GetPostsAfter(model.GetPostsOptions{ChannelId: channelId, PostId: posts[5].Id, PerPage: 2}, map[string]bool{})
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.Equal(t, []string{posts[7].Id, posts[6].Id}, postList.Order)
|
||||
@@ -1412,7 +1412,7 @@ func testPostStoreGetPostsBeforeAfter(t *testing.T, ss store.Store) {
|
||||
post2.UpdateAt = post6.UpdateAt
|
||||
|
||||
t.Run("should return each post and thread before a post", func(t *testing.T) {
|
||||
postList, err := ss.Post().GetPostsBefore(model.GetPostsOptions{ChannelId: channelId, PostId: post4.Id, PerPage: 2})
|
||||
postList, err := ss.Post().GetPostsBefore(model.GetPostsOptions{ChannelId: channelId, PostId: post4.Id, PerPage: 2}, map[string]bool{})
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.Equal(t, []string{post3.Id, post2.Id}, postList.Order)
|
||||
@@ -1426,7 +1426,7 @@ func testPostStoreGetPostsBeforeAfter(t *testing.T, ss store.Store) {
|
||||
})
|
||||
|
||||
t.Run("should return each post and the root of each thread after a post", func(t *testing.T) {
|
||||
postList, err := ss.Post().GetPostsAfter(model.GetPostsOptions{ChannelId: channelId, PostId: post4.Id, PerPage: 2})
|
||||
postList, err := ss.Post().GetPostsAfter(model.GetPostsOptions{ChannelId: channelId, PostId: post4.Id, PerPage: 2}, map[string]bool{})
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.Equal(t, []string{post6.Id, post5.Id}, postList.Order)
|
||||
@@ -1510,7 +1510,7 @@ func testPostStoreGetPostsBeforeAfter(t *testing.T, ss store.Store) {
|
||||
post2.UpdateAt = post6.UpdateAt
|
||||
|
||||
t.Run("should return each post and thread before a post", func(t *testing.T) {
|
||||
postList, err := ss.Post().GetPostsBefore(model.GetPostsOptions{ChannelId: channelId, PostId: post4.Id, PerPage: 2, SkipFetchThreads: true})
|
||||
postList, err := ss.Post().GetPostsBefore(model.GetPostsOptions{ChannelId: channelId, PostId: post4.Id, PerPage: 2, SkipFetchThreads: true}, map[string]bool{})
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.Equal(t, []string{post3.Id, post2.Id}, postList.Order)
|
||||
@@ -1522,7 +1522,7 @@ func testPostStoreGetPostsBeforeAfter(t *testing.T, ss store.Store) {
|
||||
})
|
||||
|
||||
t.Run("should return each post and thread before a post with limit", func(t *testing.T) {
|
||||
postList, err := ss.Post().GetPostsBefore(model.GetPostsOptions{ChannelId: channelId, PostId: post4.Id, PerPage: 1, SkipFetchThreads: true})
|
||||
postList, err := ss.Post().GetPostsBefore(model.GetPostsOptions{ChannelId: channelId, PostId: post4.Id, PerPage: 1, SkipFetchThreads: true}, map[string]bool{})
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.Equal(t, []string{post3.Id}, postList.Order)
|
||||
@@ -1533,7 +1533,7 @@ func testPostStoreGetPostsBeforeAfter(t *testing.T, ss store.Store) {
|
||||
})
|
||||
|
||||
t.Run("should return each post and the root of each thread after a post", func(t *testing.T) {
|
||||
postList, err := ss.Post().GetPostsAfter(model.GetPostsOptions{ChannelId: channelId, PostId: post4.Id, PerPage: 2, SkipFetchThreads: true})
|
||||
postList, err := ss.Post().GetPostsAfter(model.GetPostsOptions{ChannelId: channelId, PostId: post4.Id, PerPage: 2, SkipFetchThreads: true}, map[string]bool{})
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.Equal(t, []string{post6.Id, post5.Id}, postList.Order)
|
||||
@@ -1616,21 +1616,21 @@ func testPostStoreGetPostsBeforeAfter(t *testing.T, ss store.Store) {
|
||||
post2.UpdateAt = post6.UpdateAt
|
||||
|
||||
t.Run("should return each root post before a post", func(t *testing.T) {
|
||||
postList, err := ss.Post().GetPostsBefore(model.GetPostsOptions{ChannelId: channelId, PostId: post4.Id, PerPage: 2, CollapsedThreads: true})
|
||||
postList, err := ss.Post().GetPostsBefore(model.GetPostsOptions{ChannelId: channelId, PostId: post4.Id, PerPage: 2, CollapsedThreads: true}, map[string]bool{})
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.Equal(t, []string{post2.Id, post1.Id}, postList.Order)
|
||||
})
|
||||
|
||||
t.Run("should return each root post before a post with limit", func(t *testing.T) {
|
||||
postList, err := ss.Post().GetPostsBefore(model.GetPostsOptions{ChannelId: channelId, PostId: post4.Id, PerPage: 1, CollapsedThreads: true})
|
||||
postList, err := ss.Post().GetPostsBefore(model.GetPostsOptions{ChannelId: channelId, PostId: post4.Id, PerPage: 1, CollapsedThreads: true}, map[string]bool{})
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.Equal(t, []string{post2.Id}, postList.Order)
|
||||
})
|
||||
|
||||
t.Run("should return each root after a post", func(t *testing.T) {
|
||||
postList, err := ss.Post().GetPostsAfter(model.GetPostsOptions{ChannelId: channelId, PostId: post4.Id, PerPage: 2, CollapsedThreads: true})
|
||||
postList, err := ss.Post().GetPostsAfter(model.GetPostsOptions{ChannelId: channelId, PostId: post4.Id, PerPage: 2, CollapsedThreads: true}, map[string]bool{})
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.Equal(t, []string{post5.Id}, postList.Order)
|
||||
@@ -1693,7 +1693,7 @@ func testPostStoreGetPostsSince(t *testing.T, ss store.Store) {
|
||||
require.NoError(t, err)
|
||||
time.Sleep(time.Millisecond)
|
||||
|
||||
postList, err := ss.Post().GetPostsSince(model.GetPostsSinceOptions{ChannelId: channelId, Time: post3.CreateAt}, false)
|
||||
postList, err := ss.Post().GetPostsSince(model.GetPostsSinceOptions{ChannelId: channelId, Time: post3.CreateAt}, false, map[string]bool{})
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.Equal(t, []string{
|
||||
@@ -1724,7 +1724,7 @@ func testPostStoreGetPostsSince(t *testing.T, ss store.Store) {
|
||||
require.NoError(t, err)
|
||||
time.Sleep(time.Millisecond)
|
||||
|
||||
postList, err := ss.Post().GetPostsSince(model.GetPostsSinceOptions{ChannelId: channelId, Time: post1.CreateAt}, false)
|
||||
postList, err := ss.Post().GetPostsSince(model.GetPostsSinceOptions{ChannelId: channelId, Time: post1.CreateAt}, false, map[string]bool{})
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.Equal(t, []string{}, postList.Order)
|
||||
@@ -1746,12 +1746,12 @@ func testPostStoreGetPostsSince(t *testing.T, ss store.Store) {
|
||||
time.Sleep(time.Millisecond)
|
||||
|
||||
// Make a request that returns no results
|
||||
postList, err := ss.Post().GetPostsSince(model.GetPostsSinceOptions{ChannelId: channelId, Time: post1.CreateAt}, true)
|
||||
postList, err := ss.Post().GetPostsSince(model.GetPostsSinceOptions{ChannelId: channelId, Time: post1.CreateAt}, true, map[string]bool{})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, model.NewPostList(), postList)
|
||||
|
||||
// And then ensure that it doesn't cause future requests to also return no results
|
||||
postList, err = ss.Post().GetPostsSince(model.GetPostsSinceOptions{ChannelId: channelId, Time: post1.CreateAt - 1}, true)
|
||||
postList, err = ss.Post().GetPostsSince(model.GetPostsSinceOptions{ChannelId: channelId, Time: post1.CreateAt - 1}, true, map[string]bool{})
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.Equal(t, []string{post1.Id}, postList.Order)
|
||||
@@ -1815,7 +1815,7 @@ func testPostStoreGetPosts(t *testing.T, ss store.Store) {
|
||||
require.NoError(t, err)
|
||||
|
||||
t.Run("should return the last posts created in a channel", func(t *testing.T) {
|
||||
postList, err := ss.Post().GetPosts(model.GetPostsOptions{ChannelId: channelId, Page: 0, PerPage: 30, SkipFetchThreads: false}, false)
|
||||
postList, err := ss.Post().GetPosts(model.GetPostsOptions{ChannelId: channelId, Page: 0, PerPage: 30, SkipFetchThreads: false}, false, map[string]bool{})
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.Equal(t, []string{
|
||||
@@ -1837,7 +1837,7 @@ func testPostStoreGetPosts(t *testing.T, ss store.Store) {
|
||||
})
|
||||
|
||||
t.Run("should return the last posts created in a channel and the threads and the reply count must be 0", func(t *testing.T) {
|
||||
postList, err := ss.Post().GetPosts(model.GetPostsOptions{ChannelId: channelId, Page: 0, PerPage: 2, SkipFetchThreads: false}, false)
|
||||
postList, err := ss.Post().GetPosts(model.GetPostsOptions{ChannelId: channelId, Page: 0, PerPage: 2, SkipFetchThreads: false}, false, map[string]bool{})
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.Equal(t, []string{
|
||||
@@ -1857,7 +1857,7 @@ func testPostStoreGetPosts(t *testing.T, ss store.Store) {
|
||||
})
|
||||
|
||||
t.Run("should return the last posts created in a channel without the threads and the reply count must be correct", func(t *testing.T) {
|
||||
postList, err := ss.Post().GetPosts(model.GetPostsOptions{ChannelId: channelId, Page: 0, PerPage: 2, SkipFetchThreads: true}, false)
|
||||
postList, err := ss.Post().GetPosts(model.GetPostsOptions{ChannelId: channelId, Page: 0, PerPage: 2, SkipFetchThreads: true}, false, map[string]bool{})
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.Equal(t, []string{
|
||||
@@ -2753,23 +2753,23 @@ func testPostStoreOverwriteMultiple(t *testing.T, ss store.Store) {
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
r1, err := ss.Post().Get(context.Background(), o1.Id, model.GetPostsOptions{}, "")
|
||||
r1, err := ss.Post().Get(context.Background(), o1.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.NoError(t, err)
|
||||
ro1 := r1.Posts[o1.Id]
|
||||
|
||||
r2, err := ss.Post().Get(context.Background(), o2.Id, model.GetPostsOptions{}, "")
|
||||
r2, err := ss.Post().Get(context.Background(), o2.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.NoError(t, err)
|
||||
ro2 := r2.Posts[o2.Id]
|
||||
|
||||
r3, err := ss.Post().Get(context.Background(), o3.Id, model.GetPostsOptions{}, "")
|
||||
r3, err := ss.Post().Get(context.Background(), o3.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.NoError(t, err)
|
||||
ro3 := r3.Posts[o3.Id]
|
||||
|
||||
r4, err := ss.Post().Get(context.Background(), o4.Id, model.GetPostsOptions{}, "")
|
||||
r4, err := ss.Post().Get(context.Background(), o4.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.NoError(t, err)
|
||||
ro4 := r4.Posts[o4.Id]
|
||||
|
||||
r5, err := ss.Post().Get(context.Background(), o5.Id, model.GetPostsOptions{}, "")
|
||||
r5, err := ss.Post().Get(context.Background(), o5.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.NoError(t, err)
|
||||
ro5 := r5.Posts[o5.Id]
|
||||
|
||||
@@ -2795,15 +2795,15 @@ func testPostStoreOverwriteMultiple(t *testing.T, ss store.Store) {
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, -1, errIdx)
|
||||
|
||||
r1, nErr := ss.Post().Get(context.Background(), o1.Id, model.GetPostsOptions{}, "")
|
||||
r1, nErr := ss.Post().Get(context.Background(), o1.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.NoError(t, nErr)
|
||||
ro1a := r1.Posts[o1.Id]
|
||||
|
||||
r2, nErr = ss.Post().Get(context.Background(), o1.Id, model.GetPostsOptions{}, "")
|
||||
r2, nErr = ss.Post().Get(context.Background(), o1.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.NoError(t, nErr)
|
||||
ro2a := r2.Posts[o2.Id]
|
||||
|
||||
r3, nErr = ss.Post().Get(context.Background(), o3.Id, model.GetPostsOptions{}, "")
|
||||
r3, nErr = ss.Post().Get(context.Background(), o3.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.NoError(t, nErr)
|
||||
ro3a := r3.Posts[o3.Id]
|
||||
|
||||
@@ -2825,11 +2825,11 @@ func testPostStoreOverwriteMultiple(t *testing.T, ss store.Store) {
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, -1, errIdx)
|
||||
|
||||
r4, nErr := ss.Post().Get(context.Background(), o4.Id, model.GetPostsOptions{}, "")
|
||||
r4, nErr := ss.Post().Get(context.Background(), o4.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.NoError(t, nErr)
|
||||
ro4a := r4.Posts[o4.Id]
|
||||
|
||||
r5, nErr = ss.Post().Get(context.Background(), o5.Id, model.GetPostsOptions{}, "")
|
||||
r5, nErr = ss.Post().Get(context.Background(), o5.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.NoError(t, nErr)
|
||||
ro5a := r5.Posts[o5.Id]
|
||||
|
||||
@@ -2871,19 +2871,19 @@ func testPostStoreOverwrite(t *testing.T, ss store.Store) {
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
r1, err := ss.Post().Get(context.Background(), o1.Id, model.GetPostsOptions{}, "")
|
||||
r1, err := ss.Post().Get(context.Background(), o1.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.NoError(t, err)
|
||||
ro1 := r1.Posts[o1.Id]
|
||||
|
||||
r2, err := ss.Post().Get(context.Background(), o2.Id, model.GetPostsOptions{}, "")
|
||||
r2, err := ss.Post().Get(context.Background(), o2.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.NoError(t, err)
|
||||
ro2 := r2.Posts[o2.Id]
|
||||
|
||||
r3, err := ss.Post().Get(context.Background(), o3.Id, model.GetPostsOptions{}, "")
|
||||
r3, err := ss.Post().Get(context.Background(), o3.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.NoError(t, err)
|
||||
ro3 := r3.Posts[o3.Id]
|
||||
|
||||
r4, err := ss.Post().Get(context.Background(), o4.Id, model.GetPostsOptions{}, "")
|
||||
r4, err := ss.Post().Get(context.Background(), o4.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.NoError(t, err)
|
||||
ro4 := r4.Posts[o4.Id]
|
||||
|
||||
@@ -2908,15 +2908,15 @@ func testPostStoreOverwrite(t *testing.T, ss store.Store) {
|
||||
_, err = ss.Post().Overwrite(o3a)
|
||||
require.NoError(t, err)
|
||||
|
||||
r1, err = ss.Post().Get(context.Background(), o1.Id, model.GetPostsOptions{}, "")
|
||||
r1, err = ss.Post().Get(context.Background(), o1.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.NoError(t, err)
|
||||
ro1a := r1.Posts[o1.Id]
|
||||
|
||||
r2, err = ss.Post().Get(context.Background(), o1.Id, model.GetPostsOptions{}, "")
|
||||
r2, err = ss.Post().Get(context.Background(), o1.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.NoError(t, err)
|
||||
ro2a := r2.Posts[o2.Id]
|
||||
|
||||
r3, err = ss.Post().Get(context.Background(), o3.Id, model.GetPostsOptions{}, "")
|
||||
r3, err = ss.Post().Get(context.Background(), o3.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.NoError(t, err)
|
||||
ro3a := r3.Posts[o3.Id]
|
||||
|
||||
@@ -2932,7 +2932,7 @@ func testPostStoreOverwrite(t *testing.T, ss store.Store) {
|
||||
_, err = ss.Post().Overwrite(o4a)
|
||||
require.NoError(t, err)
|
||||
|
||||
r4, err = ss.Post().Get(context.Background(), o4.Id, model.GetPostsOptions{}, "")
|
||||
r4, err = ss.Post().Get(context.Background(), o4.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.NoError(t, err)
|
||||
|
||||
ro4a := r4.Posts[o4.Id]
|
||||
@@ -2963,15 +2963,15 @@ func testPostStoreGetPostsByIds(t *testing.T, ss store.Store) {
|
||||
o3, err = ss.Post().Save(o3)
|
||||
require.NoError(t, err)
|
||||
|
||||
r1, err := ss.Post().Get(context.Background(), o1.Id, model.GetPostsOptions{}, "")
|
||||
r1, err := ss.Post().Get(context.Background(), o1.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.NoError(t, err)
|
||||
ro1 := r1.Posts[o1.Id]
|
||||
|
||||
r2, err := ss.Post().Get(context.Background(), o2.Id, model.GetPostsOptions{}, "")
|
||||
r2, err := ss.Post().Get(context.Background(), o2.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.NoError(t, err)
|
||||
ro2 := r2.Posts[o2.Id]
|
||||
|
||||
r3, err := ss.Post().Get(context.Background(), o3.Id, model.GetPostsOptions{}, "")
|
||||
r3, err := ss.Post().Get(context.Background(), o3.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.NoError(t, err)
|
||||
ro3 := r3.Posts[o3.Id]
|
||||
|
||||
@@ -3096,13 +3096,13 @@ func testPostStorePermanentDeleteBatch(t *testing.T, ss store.Store) {
|
||||
_, _, err = ss.Post().PermanentDeleteBatchForRetentionPolicies(0, 2000, 1000, model.RetentionPolicyCursor{})
|
||||
require.NoError(t, err)
|
||||
|
||||
_, err = ss.Post().Get(context.Background(), o1.Id, model.GetPostsOptions{}, "")
|
||||
_, err = ss.Post().Get(context.Background(), o1.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.Error(t, err, "Should have not found post 1 after purge")
|
||||
|
||||
_, err = ss.Post().Get(context.Background(), o2.Id, model.GetPostsOptions{}, "")
|
||||
_, err = ss.Post().Get(context.Background(), o2.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.Error(t, err, "Should have not found post 2 after purge")
|
||||
|
||||
_, err = ss.Post().Get(context.Background(), o3.Id, model.GetPostsOptions{}, "")
|
||||
_, err = ss.Post().Get(context.Background(), o3.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.NoError(t, err, "Should have found post 3 after purge")
|
||||
|
||||
t.Run("with pagination", func(t *testing.T) {
|
||||
@@ -3146,13 +3146,13 @@ func testPostStorePermanentDeleteBatch(t *testing.T, ss store.Store) {
|
||||
|
||||
_, _, err2 = ss.Post().PermanentDeleteBatchForRetentionPolicies(0, 2000, 1000, model.RetentionPolicyCursor{})
|
||||
require.NoError(t, err2)
|
||||
_, err2 = ss.Post().Get(context.Background(), post.Id, model.GetPostsOptions{}, "")
|
||||
_, err2 = ss.Post().Get(context.Background(), post.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.NoError(t, err2, "global policy should have been ignored due to granular policy")
|
||||
|
||||
nowMillis := post.CreateAt + *channelPolicy.PostDurationDays*model.DayInMilliseconds + 1
|
||||
_, _, err2 = ss.Post().PermanentDeleteBatchForRetentionPolicies(nowMillis, 0, 1000, model.RetentionPolicyCursor{})
|
||||
require.NoError(t, err2)
|
||||
_, err2 = ss.Post().Get(context.Background(), post.Id, model.GetPostsOptions{}, "")
|
||||
_, err2 = ss.Post().Get(context.Background(), post.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.Error(t, err2, "post should have been deleted by channel policy")
|
||||
|
||||
// Create a team policy which is stricter than the channel policy
|
||||
@@ -3171,7 +3171,7 @@ func testPostStorePermanentDeleteBatch(t *testing.T, ss store.Store) {
|
||||
nowMillis = post.CreateAt + *teamPolicy.PostDurationDays*model.DayInMilliseconds + 1
|
||||
_, _, err2 = ss.Post().PermanentDeleteBatchForRetentionPolicies(nowMillis, 0, 1000, model.RetentionPolicyCursor{})
|
||||
require.NoError(t, err2)
|
||||
_, err2 = ss.Post().Get(context.Background(), post.Id, model.GetPostsOptions{}, "")
|
||||
_, err2 = ss.Post().Get(context.Background(), post.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.NoError(t, err2, "channel policy should have overridden team policy")
|
||||
|
||||
// Delete channel policy and re-run team policy
|
||||
@@ -3183,7 +3183,7 @@ func testPostStorePermanentDeleteBatch(t *testing.T, ss store.Store) {
|
||||
|
||||
_, _, err2 = ss.Post().PermanentDeleteBatchForRetentionPolicies(nowMillis, 0, 1000, model.RetentionPolicyCursor{})
|
||||
require.NoError(t, err2)
|
||||
_, err2 = ss.Post().Get(context.Background(), post.Id, model.GetPostsOptions{}, "")
|
||||
_, err2 = ss.Post().Get(context.Background(), post.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.Error(t, err2, "post should have been deleted by team policy")
|
||||
|
||||
err2 = ss.RetentionPolicy().RemoveTeams(teamPolicy.ID, []string{team.Id})
|
||||
|
||||
@@ -55,7 +55,7 @@ func testReactionSave(t *testing.T, ss store.Store) {
|
||||
assert.Zero(t, saved.DeleteAt, "should've saved reaction delete_at with zero value and returned it")
|
||||
|
||||
var secondUpdateAt int64
|
||||
postList, err := ss.Post().Get(context.Background(), reaction1.PostId, model.GetPostsOptions{}, "")
|
||||
postList, err := ss.Post().Get(context.Background(), reaction1.PostId, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.True(t, postList.Posts[post.Id].HasReactions, "should've set HasReactions = true on post")
|
||||
@@ -79,7 +79,7 @@ func testReactionSave(t *testing.T, ss store.Store) {
|
||||
_, nErr = ss.Reaction().Save(reaction2)
|
||||
require.NoError(t, nErr)
|
||||
|
||||
postList, err = ss.Post().Get(context.Background(), reaction2.PostId, model.GetPostsOptions{}, "")
|
||||
postList, err = ss.Post().Get(context.Background(), reaction2.PostId, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.NotEqual(t, postList.Posts[post.Id].UpdateAt, secondUpdateAt, "should've marked post as updated even if HasReactions doesn't change")
|
||||
@@ -129,7 +129,7 @@ func testReactionDelete(t *testing.T, ss store.Store) {
|
||||
_, nErr := ss.Reaction().Save(reaction)
|
||||
require.NoError(t, nErr)
|
||||
|
||||
result, err := ss.Post().Get(context.Background(), reaction.PostId, model.GetPostsOptions{}, "")
|
||||
result, err := ss.Post().Get(context.Background(), reaction.PostId, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.NoError(t, err)
|
||||
|
||||
firstUpdateAt := result.Posts[post.Id].UpdateAt
|
||||
@@ -142,7 +142,7 @@ func testReactionDelete(t *testing.T, ss store.Store) {
|
||||
|
||||
assert.Empty(t, reactions, "should've deleted reaction")
|
||||
|
||||
postList, err := ss.Post().Get(context.Background(), post.Id, model.GetPostsOptions{}, "")
|
||||
postList, err := ss.Post().Get(context.Background(), post.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.False(t, postList.Posts[post.Id].HasReactions, "should've set HasReactions = false on post")
|
||||
@@ -507,15 +507,15 @@ func testReactionDeleteAllWithEmojiName(t *testing.T, ss store.Store, s SqlStore
|
||||
assert.Empty(t, returned, "should've only removed reactions with emoji name")
|
||||
|
||||
// check that the posts are updated
|
||||
postList, err := ss.Post().Get(context.Background(), post.Id, model.GetPostsOptions{}, "")
|
||||
postList, err := ss.Post().Get(context.Background(), post.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.NoError(t, err)
|
||||
assert.True(t, postList.Posts[post.Id].HasReactions, "post should still have reactions")
|
||||
|
||||
postList, err = ss.Post().Get(context.Background(), post2.Id, model.GetPostsOptions{}, "")
|
||||
postList, err = ss.Post().Get(context.Background(), post2.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.NoError(t, err)
|
||||
assert.True(t, postList.Posts[post2.Id].HasReactions, "post should still have reactions")
|
||||
|
||||
postList, err = ss.Post().Get(context.Background(), post3.Id, model.GetPostsOptions{}, "")
|
||||
postList, err = ss.Post().Get(context.Background(), post3.Id, model.GetPostsOptions{}, "", map[string]bool{})
|
||||
require.NoError(t, err)
|
||||
assert.False(t, postList.Posts[post3.Id].HasReactions, "post shouldn't have reactions any more")
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ func testThreadStorePopulation(t *testing.T, ss store.Store) {
|
||||
opts := model.GetPostsOptions{
|
||||
SkipFetchThreads: true,
|
||||
}
|
||||
olist, _ := ss.Post().Get(context.Background(), otmp.Id, opts, "")
|
||||
olist, _ := ss.Post().Get(context.Background(), otmp.Id, opts, "", map[string]bool{})
|
||||
o1 := olist.Posts[olist.Order[0]]
|
||||
|
||||
newPosts = append([]*model.Post{o1}, newPosts...)
|
||||
|
||||
Ссылка в новой задаче
Block a user