MM-33544 is_following prop in getPosts API methods (#17093)
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
c0971970e9
Коммит
0cc72342de
@@ -102,13 +102,13 @@ func (_m *PostStore) Delete(postID string, time int64, deleteByID string) error
|
||||
return r0
|
||||
}
|
||||
|
||||
// Get provides a mock function with given fields: ctx, id, skipFetchThreads, collapsedThreads, collapsedThreadsExtended
|
||||
func (_m *PostStore) Get(ctx context.Context, id string, skipFetchThreads bool, collapsedThreads bool, collapsedThreadsExtended bool) (*model.PostList, error) {
|
||||
ret := _m.Called(ctx, id, skipFetchThreads, collapsedThreads, collapsedThreadsExtended)
|
||||
// Get provides a mock function with given fields: ctx, id, skipFetchThreads, collapsedThreads, collapsedThreadsExtended, userID
|
||||
func (_m *PostStore) Get(ctx context.Context, id string, skipFetchThreads bool, collapsedThreads bool, collapsedThreadsExtended bool, userID string) (*model.PostList, error) {
|
||||
ret := _m.Called(ctx, id, skipFetchThreads, collapsedThreads, collapsedThreadsExtended, userID)
|
||||
|
||||
var r0 *model.PostList
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string, bool, bool, bool) *model.PostList); ok {
|
||||
r0 = rf(ctx, id, skipFetchThreads, collapsedThreads, collapsedThreadsExtended)
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string, bool, bool, bool, string) *model.PostList); ok {
|
||||
r0 = rf(ctx, id, skipFetchThreads, collapsedThreads, collapsedThreadsExtended, userID)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*model.PostList)
|
||||
@@ -116,8 +116,8 @@ func (_m *PostStore) Get(ctx context.Context, id string, skipFetchThreads bool,
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(context.Context, string, bool, bool, bool) error); ok {
|
||||
r1 = rf(ctx, id, skipFetchThreads, collapsedThreads, collapsedThreadsExtended)
|
||||
if rf, ok := ret.Get(1).(func(context.Context, string, bool, bool, bool, string) error); ok {
|
||||
r1 = rf(ctx, id, skipFetchThreads, collapsedThreads, collapsedThreadsExtended, userID)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
@@ -55,6 +55,8 @@ func TestPostStore(t *testing.T, ss store.Store, s SqlStore) {
|
||||
t.Run("GetDirectPostParentsForExportAfter", func(t *testing.T) { testPostStoreGetDirectPostParentsForExportAfter(t, ss, s) })
|
||||
t.Run("GetDirectPostParentsForExportAfterDeleted", func(t *testing.T) { testPostStoreGetDirectPostParentsForExportAfterDeleted(t, ss, s) })
|
||||
t.Run("GetDirectPostParentsForExportAfterBatched", func(t *testing.T) { testPostStoreGetDirectPostParentsForExportAfterBatched(t, ss, s) })
|
||||
t.Run("GetForThread", func(t *testing.T) { testPostStoreGetForThread(t, ss) })
|
||||
|
||||
}
|
||||
|
||||
func testPostStoreSave(t *testing.T, ss store.Store) {
|
||||
@@ -417,17 +419,40 @@ 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, false, false, false)
|
||||
r1, err := ss.Post().Get(context.Background(), o1.Id, false, false, false, "")
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, r1.Posts[o1.Id].CreateAt, o1.CreateAt, "invalid returned post")
|
||||
|
||||
_, err = ss.Post().Get(context.Background(), "123", false, false, false)
|
||||
_, err = ss.Post().Get(context.Background(), "123", false, false, false, "")
|
||||
require.Error(t, err, "Missing id should have failed")
|
||||
|
||||
_, err = ss.Post().Get(context.Background(), "", false, false, false)
|
||||
_, err = ss.Post().Get(context.Background(), "", false, false, false, "")
|
||||
require.Error(t, err, "should fail for blank post ids")
|
||||
}
|
||||
|
||||
func testPostStoreGetForThread(t *testing.T, ss store.Store) {
|
||||
o1 := &model.Post{ChannelId: model.NewId(), UserId: model.NewId(), Message: "zz" + model.NewId() + "b"}
|
||||
o1, err := ss.Post().Save(o1)
|
||||
require.NoError(t, err)
|
||||
_, err = ss.Post().Save(&model.Post{ChannelId: o1.ChannelId, UserId: model.NewId(), Message: "zz" + model.NewId() + "b", RootId: o1.Id})
|
||||
require.NoError(t, err)
|
||||
|
||||
threadMembership := &model.ThreadMembership{
|
||||
PostId: o1.Id,
|
||||
UserId: o1.UserId,
|
||||
Following: true,
|
||||
LastViewed: 0,
|
||||
LastUpdated: 0,
|
||||
UnreadMentions: 0,
|
||||
}
|
||||
_, err = ss.Thread().SaveMembership(threadMembership)
|
||||
require.NoError(t, err)
|
||||
r1, err := ss.Post().Get(context.Background(), o1.Id, false, true, false, o1.UserId)
|
||||
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)
|
||||
}
|
||||
|
||||
func testPostStoreGetSingle(t *testing.T, ss store.Store) {
|
||||
o1 := &model.Post{}
|
||||
o1.ChannelId = model.NewId()
|
||||
@@ -469,15 +494,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, false, false, false)
|
||||
r1, err := ss.Post().Get(context.Background(), o1.Id, false, false, false, "")
|
||||
require.NoError(t, err)
|
||||
ro1 := r1.Posts[o1.Id]
|
||||
|
||||
r2, err := ss.Post().Get(context.Background(), o1.Id, false, false, false)
|
||||
r2, err := ss.Post().Get(context.Background(), o1.Id, false, false, false, "")
|
||||
require.NoError(t, err)
|
||||
ro2 := r2.Posts[o2.Id]
|
||||
|
||||
r3, err := ss.Post().Get(context.Background(), o3.Id, false, false, false)
|
||||
r3, err := ss.Post().Get(context.Background(), o3.Id, false, false, false, "")
|
||||
require.NoError(t, err)
|
||||
ro3 := r3.Posts[o3.Id]
|
||||
|
||||
@@ -488,7 +513,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, false, false, false)
|
||||
r1, err = ss.Post().Get(context.Background(), o1.Id, false, false, false, "")
|
||||
require.NoError(t, err)
|
||||
|
||||
ro1a := r1.Posts[o1.Id]
|
||||
@@ -499,7 +524,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, false, false, false)
|
||||
r2, err = ss.Post().Get(context.Background(), o1.Id, false, false, false, "")
|
||||
require.NoError(t, err)
|
||||
ro2a := r2.Posts[o2.Id]
|
||||
|
||||
@@ -510,7 +535,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, false, false, false)
|
||||
r3, err = ss.Post().Get(context.Background(), o3.Id, false, false, false, "")
|
||||
require.NoError(t, err)
|
||||
ro3a := r3.Posts[o3.Id]
|
||||
|
||||
@@ -526,7 +551,7 @@ func testPostStoreUpdate(t *testing.T, ss store.Store) {
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
r4, err := ss.Post().Get(context.Background(), o4.Id, false, false, false)
|
||||
r4, err := ss.Post().Get(context.Background(), o4.Id, false, false, false, "")
|
||||
require.NoError(t, err)
|
||||
ro4 := r4.Posts[o4.Id]
|
||||
|
||||
@@ -536,7 +561,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, false, false, false)
|
||||
r4, err = ss.Post().Get(context.Background(), o4.Id, false, false, false, "")
|
||||
require.NoError(t, err)
|
||||
|
||||
ro4a := r4.Posts[o4.Id]
|
||||
@@ -557,7 +582,7 @@ func testPostStoreDelete(t *testing.T, ss store.Store) {
|
||||
o1, err := ss.Post().Save(o1)
|
||||
require.NoError(t, err)
|
||||
|
||||
r1, err := ss.Post().Get(context.Background(), o1.Id, false, false, false)
|
||||
r1, err := ss.Post().Get(context.Background(), o1.Id, false, false, false, "")
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, r1.Posts[o1.Id].CreateAt, o1.CreateAt, "invalid returned post")
|
||||
|
||||
@@ -570,7 +595,7 @@ func testPostStoreDelete(t *testing.T, ss store.Store) {
|
||||
|
||||
assert.Equal(t, deleteByID, actual, "Expected (*Post).Props[model.POST_PROPS_DELETE_BY] to be %v but got %v.", deleteByID, actual)
|
||||
|
||||
r3, err := ss.Post().Get(context.Background(), o1.Id, false, false, false)
|
||||
r3, err := ss.Post().Get(context.Background(), o1.Id, false, false, false, "")
|
||||
require.Error(t, err, "Missing id should have failed - PostList %v", r3)
|
||||
|
||||
etag2 := ss.Post().GetEtag(o1.ChannelId, false, false)
|
||||
@@ -597,10 +622,10 @@ func testPostStoreDelete1Level(t *testing.T, ss store.Store) {
|
||||
err = ss.Post().Delete(o1.Id, model.GetMillis(), "")
|
||||
require.NoError(t, err)
|
||||
|
||||
_, err = ss.Post().Get(context.Background(), o1.Id, false, false, false)
|
||||
_, err = ss.Post().Get(context.Background(), o1.Id, false, false, false, "")
|
||||
require.Error(t, err, "Deleted id should have failed")
|
||||
|
||||
_, err = ss.Post().Get(context.Background(), o2.Id, false, false, false)
|
||||
_, err = ss.Post().Get(context.Background(), o2.Id, false, false, false, "")
|
||||
require.Error(t, err, "Deleted id should have failed")
|
||||
}
|
||||
|
||||
@@ -640,16 +665,16 @@ func testPostStoreDelete2Level(t *testing.T, ss store.Store) {
|
||||
err = ss.Post().Delete(o1.Id, model.GetMillis(), "")
|
||||
require.NoError(t, err)
|
||||
|
||||
_, err = ss.Post().Get(context.Background(), o1.Id, false, false, false)
|
||||
_, err = ss.Post().Get(context.Background(), o1.Id, false, false, false, "")
|
||||
require.Error(t, err, "Deleted id should have failed")
|
||||
|
||||
_, err = ss.Post().Get(context.Background(), o2.Id, false, false, false)
|
||||
_, err = ss.Post().Get(context.Background(), o2.Id, false, false, false, "")
|
||||
require.Error(t, err, "Deleted id should have failed")
|
||||
|
||||
_, err = ss.Post().Get(context.Background(), o3.Id, false, false, false)
|
||||
_, err = ss.Post().Get(context.Background(), o3.Id, false, false, false, "")
|
||||
require.Error(t, err, "Deleted id should have failed")
|
||||
|
||||
_, err = ss.Post().Get(context.Background(), o4.Id, false, false, false)
|
||||
_, err = ss.Post().Get(context.Background(), o4.Id, false, false, false, "")
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
@@ -680,16 +705,16 @@ func testPostStorePermDelete1Level(t *testing.T, ss store.Store) {
|
||||
err2 := ss.Post().PermanentDeleteByUser(o2.UserId)
|
||||
require.NoError(t, err2)
|
||||
|
||||
_, err = ss.Post().Get(context.Background(), o1.Id, false, false, false)
|
||||
_, err = ss.Post().Get(context.Background(), o1.Id, false, false, false, "")
|
||||
require.NoError(t, err, "Deleted id shouldn't have failed")
|
||||
|
||||
_, err = ss.Post().Get(context.Background(), o2.Id, false, false, false)
|
||||
_, err = ss.Post().Get(context.Background(), o2.Id, false, false, false, "")
|
||||
require.Error(t, err, "Deleted id should have failed")
|
||||
|
||||
err = ss.Post().PermanentDeleteByChannel(o3.ChannelId)
|
||||
require.NoError(t, err)
|
||||
|
||||
_, err = ss.Post().Get(context.Background(), o3.Id, false, false, false)
|
||||
_, err = ss.Post().Get(context.Background(), o3.Id, false, false, false, "")
|
||||
require.Error(t, err, "Deleted id should have failed")
|
||||
}
|
||||
|
||||
@@ -720,13 +745,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, false, false, false)
|
||||
_, err = ss.Post().Get(context.Background(), o1.Id, false, false, false, "")
|
||||
require.Error(t, err, "Deleted id should have failed")
|
||||
|
||||
_, err = ss.Post().Get(context.Background(), o2.Id, false, false, false)
|
||||
_, err = ss.Post().Get(context.Background(), o2.Id, false, false, false, "")
|
||||
require.Error(t, err, "Deleted id should have failed")
|
||||
|
||||
_, err = ss.Post().Get(context.Background(), o3.Id, false, false, false)
|
||||
_, err = ss.Post().Get(context.Background(), o3.Id, false, false, false, "")
|
||||
require.NoError(t, err, "Deleted id should have failed")
|
||||
}
|
||||
|
||||
@@ -756,7 +781,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, false, false, false)
|
||||
pl, err := ss.Post().Get(context.Background(), o1.Id, false, false, false, "")
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, pl.Posts, 3, "invalid returned post")
|
||||
@@ -764,7 +789,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, false, false, false)
|
||||
pl, err = ss.Post().Get(context.Background(), o1.Id, false, false, false, "")
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, pl.Posts, 2, "invalid returned post")
|
||||
@@ -772,7 +797,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, false, false, false)
|
||||
pl, err = ss.Post().Get(context.Background(), o1.Id, false, false, false, "")
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, pl.Posts, 1, "invalid returned post")
|
||||
@@ -2242,23 +2267,23 @@ func testPostStoreOverwriteMultiple(t *testing.T, ss store.Store) {
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
r1, err := ss.Post().Get(context.Background(), o1.Id, false, false, false)
|
||||
r1, err := ss.Post().Get(context.Background(), o1.Id, false, false, false, "")
|
||||
require.NoError(t, err)
|
||||
ro1 := r1.Posts[o1.Id]
|
||||
|
||||
r2, err := ss.Post().Get(context.Background(), o2.Id, false, false, false)
|
||||
r2, err := ss.Post().Get(context.Background(), o2.Id, false, false, false, "")
|
||||
require.NoError(t, err)
|
||||
ro2 := r2.Posts[o2.Id]
|
||||
|
||||
r3, err := ss.Post().Get(context.Background(), o3.Id, false, false, false)
|
||||
r3, err := ss.Post().Get(context.Background(), o3.Id, false, false, false, "")
|
||||
require.NoError(t, err)
|
||||
ro3 := r3.Posts[o3.Id]
|
||||
|
||||
r4, err := ss.Post().Get(context.Background(), o4.Id, false, false, false)
|
||||
r4, err := ss.Post().Get(context.Background(), o4.Id, false, false, false, "")
|
||||
require.NoError(t, err)
|
||||
ro4 := r4.Posts[o4.Id]
|
||||
|
||||
r5, err := ss.Post().Get(context.Background(), o5.Id, false, false, false)
|
||||
r5, err := ss.Post().Get(context.Background(), o5.Id, false, false, false, "")
|
||||
require.NoError(t, err)
|
||||
ro5 := r5.Posts[o5.Id]
|
||||
|
||||
@@ -2284,15 +2309,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, false, false, false)
|
||||
r1, nErr := ss.Post().Get(context.Background(), o1.Id, false, false, false, "")
|
||||
require.NoError(t, nErr)
|
||||
ro1a := r1.Posts[o1.Id]
|
||||
|
||||
r2, nErr = ss.Post().Get(context.Background(), o1.Id, false, false, false)
|
||||
r2, nErr = ss.Post().Get(context.Background(), o1.Id, false, false, false, "")
|
||||
require.NoError(t, nErr)
|
||||
ro2a := r2.Posts[o2.Id]
|
||||
|
||||
r3, nErr = ss.Post().Get(context.Background(), o3.Id, false, false, false)
|
||||
r3, nErr = ss.Post().Get(context.Background(), o3.Id, false, false, false, "")
|
||||
require.NoError(t, nErr)
|
||||
ro3a := r3.Posts[o3.Id]
|
||||
|
||||
@@ -2314,11 +2339,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, false, false, false)
|
||||
r4, nErr := ss.Post().Get(context.Background(), o4.Id, false, false, false, "")
|
||||
require.NoError(t, nErr)
|
||||
ro4a := r4.Posts[o4.Id]
|
||||
|
||||
r5, nErr = ss.Post().Get(context.Background(), o5.Id, false, false, false)
|
||||
r5, nErr = ss.Post().Get(context.Background(), o5.Id, false, false, false, "")
|
||||
require.NoError(t, nErr)
|
||||
ro5a := r5.Posts[o5.Id]
|
||||
|
||||
@@ -2361,19 +2386,19 @@ func testPostStoreOverwrite(t *testing.T, ss store.Store) {
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
r1, err := ss.Post().Get(context.Background(), o1.Id, false, false, false)
|
||||
r1, err := ss.Post().Get(context.Background(), o1.Id, false, false, false, "")
|
||||
require.NoError(t, err)
|
||||
ro1 := r1.Posts[o1.Id]
|
||||
|
||||
r2, err := ss.Post().Get(context.Background(), o2.Id, false, false, false)
|
||||
r2, err := ss.Post().Get(context.Background(), o2.Id, false, false, false, "")
|
||||
require.NoError(t, err)
|
||||
ro2 := r2.Posts[o2.Id]
|
||||
|
||||
r3, err := ss.Post().Get(context.Background(), o3.Id, false, false, false)
|
||||
r3, err := ss.Post().Get(context.Background(), o3.Id, false, false, false, "")
|
||||
require.NoError(t, err)
|
||||
ro3 := r3.Posts[o3.Id]
|
||||
|
||||
r4, err := ss.Post().Get(context.Background(), o4.Id, false, false, false)
|
||||
r4, err := ss.Post().Get(context.Background(), o4.Id, false, false, false, "")
|
||||
require.NoError(t, err)
|
||||
ro4 := r4.Posts[o4.Id]
|
||||
|
||||
@@ -2398,15 +2423,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, false, false, false)
|
||||
r1, err = ss.Post().Get(context.Background(), o1.Id, false, false, false, "")
|
||||
require.NoError(t, err)
|
||||
ro1a := r1.Posts[o1.Id]
|
||||
|
||||
r2, err = ss.Post().Get(context.Background(), o1.Id, false, false, false)
|
||||
r2, err = ss.Post().Get(context.Background(), o1.Id, false, false, false, "")
|
||||
require.NoError(t, err)
|
||||
ro2a := r2.Posts[o2.Id]
|
||||
|
||||
r3, err = ss.Post().Get(context.Background(), o3.Id, false, false, false)
|
||||
r3, err = ss.Post().Get(context.Background(), o3.Id, false, false, false, "")
|
||||
require.NoError(t, err)
|
||||
ro3a := r3.Posts[o3.Id]
|
||||
|
||||
@@ -2422,7 +2447,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, false, false, false)
|
||||
r4, err = ss.Post().Get(context.Background(), o4.Id, false, false, false, "")
|
||||
require.NoError(t, err)
|
||||
|
||||
ro4a := r4.Posts[o4.Id]
|
||||
@@ -2453,15 +2478,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, false, false, false)
|
||||
r1, err := ss.Post().Get(context.Background(), o1.Id, false, false, false, "")
|
||||
require.NoError(t, err)
|
||||
ro1 := r1.Posts[o1.Id]
|
||||
|
||||
r2, err := ss.Post().Get(context.Background(), o2.Id, false, false, false)
|
||||
r2, err := ss.Post().Get(context.Background(), o2.Id, false, false, false, "")
|
||||
require.NoError(t, err)
|
||||
ro2 := r2.Posts[o2.Id]
|
||||
|
||||
r3, err := ss.Post().Get(context.Background(), o3.Id, false, false, false)
|
||||
r3, err := ss.Post().Get(context.Background(), o3.Id, false, false, false, "")
|
||||
require.NoError(t, err)
|
||||
ro3 := r3.Posts[o3.Id]
|
||||
|
||||
@@ -2568,13 +2593,13 @@ func testPostStorePermanentDeleteBatch(t *testing.T, ss store.Store) {
|
||||
_, err = ss.Post().PermanentDeleteBatch(2000, 1000)
|
||||
require.NoError(t, err)
|
||||
|
||||
_, err = ss.Post().Get(context.Background(), o1.Id, false, false, false)
|
||||
_, err = ss.Post().Get(context.Background(), o1.Id, false, false, false, "")
|
||||
require.Error(t, err, "Should have not found post 1 after purge")
|
||||
|
||||
_, err = ss.Post().Get(context.Background(), o2.Id, false, false, false)
|
||||
_, err = ss.Post().Get(context.Background(), o2.Id, false, false, false, "")
|
||||
require.Error(t, err, "Should have not found post 2 after purge")
|
||||
|
||||
_, err = ss.Post().Get(context.Background(), o3.Id, false, false, false)
|
||||
_, err = ss.Post().Get(context.Background(), o3.Id, false, false, false, "")
|
||||
require.NoError(t, err, "Should have not found post 3 after purge")
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,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, false, false, false)
|
||||
postList, err := ss.Post().Get(context.Background(), reaction1.PostId, false, false, false, "")
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.True(t, postList.Posts[post.Id].HasReactions, "should've set HasReactions = true on post")
|
||||
@@ -77,7 +77,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, false, false, false)
|
||||
postList, err = ss.Post().Get(context.Background(), reaction2.PostId, false, false, false, "")
|
||||
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")
|
||||
@@ -127,7 +127,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, false, false, false)
|
||||
result, err := ss.Post().Get(context.Background(), reaction.PostId, false, false, false, "")
|
||||
require.NoError(t, err)
|
||||
|
||||
firstUpdateAt := result.Posts[post.Id].UpdateAt
|
||||
@@ -140,7 +140,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, false, false, false)
|
||||
postList, err := ss.Post().Get(context.Background(), post.Id, false, false, false, "")
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.False(t, postList.Posts[post.Id].HasReactions, "should've set HasReactions = false on post")
|
||||
@@ -326,11 +326,11 @@ func testReactionDeleteAllWithEmojiName(t *testing.T, ss store.Store, s SqlStore
|
||||
|
||||
// make at least one Reaction record contain NULL for Update and DeleteAt to simulate post schema upgrade case.
|
||||
sqlResult, err := s.GetMaster().Exec(`
|
||||
UPDATE
|
||||
Reactions
|
||||
SET
|
||||
UpdateAt=NULL, DeleteAt=NULL
|
||||
WHERE
|
||||
UPDATE
|
||||
Reactions
|
||||
SET
|
||||
UpdateAt=NULL, DeleteAt=NULL
|
||||
WHERE
|
||||
UserId = :UserId AND PostId = :PostId AND EmojiName = :EmojiName`,
|
||||
map[string]interface{}{
|
||||
"UserId": userId,
|
||||
@@ -363,15 +363,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, false, false, false)
|
||||
postList, err := ss.Post().Get(context.Background(), post.Id, false, false, false, "")
|
||||
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, false, false, false)
|
||||
postList, err = ss.Post().Get(context.Background(), post2.Id, false, false, false, "")
|
||||
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, false, false, false)
|
||||
postList, err = ss.Post().Get(context.Background(), post3.Id, false, false, false, "")
|
||||
require.NoError(t, err)
|
||||
assert.False(t, postList.Posts[post3.Id].HasReactions, "post shouldn't have reactions any more")
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ func testThreadStorePopulation(t *testing.T, ss store.Store) {
|
||||
|
||||
newPosts, errIdx, err3 := ss.Post().SaveMultiple([]*model.Post{&o2, &o3, &o4})
|
||||
|
||||
olist, _ := ss.Post().Get(context.Background(), otmp.Id, true, false, false)
|
||||
olist, _ := ss.Post().Get(context.Background(), otmp.Id, true, false, false, "")
|
||||
o1 := olist.Posts[olist.Order[0]]
|
||||
|
||||
newPosts = append([]*model.Post{o1}, newPosts...)
|
||||
|
||||
Ссылка в новой задаче
Block a user