Automatic Merge
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
12dce033d6
Коммит
21a86506f9
@@ -34,9 +34,10 @@ func TestRestorePostVersion(t *testing.T) {
|
||||
require.Equal(t, "new message 2", editHistory[0].Message)
|
||||
|
||||
// now we'll restore a post version
|
||||
restoredPost, appErr := th.App.RestorePostVersion(th.Context, th.BasicUser.Id, post.Id, editHistory[0].Id)
|
||||
restoredPost, isMemberForPreview, appErr := th.App.RestorePostVersion(th.Context, th.BasicUser.Id, post.Id, editHistory[0].Id)
|
||||
require.Nil(t, appErr)
|
||||
require.Equal(t, "new message 2", restoredPost.Message)
|
||||
require.True(t, isMemberForPreview)
|
||||
|
||||
// verify from database
|
||||
fetchedPost, err = th.App.Srv().Store().Post().GetSingle(th.Context, post.Id, true)
|
||||
@@ -85,10 +86,11 @@ func TestRestorePostVersion(t *testing.T) {
|
||||
require.Equal(t, 1, len(editHistory[1].FileIds))
|
||||
|
||||
// now we'll restore a post version
|
||||
restoredPost, appErr := th.App.RestorePostVersion(th.Context, th.BasicUser.Id, post.Id, editHistory[1].Id)
|
||||
restoredPost, isMemberForPreview, appErr := th.App.RestorePostVersion(th.Context, th.BasicUser.Id, post.Id, editHistory[1].Id)
|
||||
require.Nil(t, appErr)
|
||||
require.Equal(t, "original message", restoredPost.Message)
|
||||
require.Equal(t, 1, len(restoredPost.FileIds))
|
||||
require.True(t, isMemberForPreview)
|
||||
|
||||
// verify from database
|
||||
fetchedPost, err = th.App.Srv().Store().Post().GetSingle(th.Context, post.Id, true)
|
||||
@@ -125,7 +127,7 @@ func TestRestorePostVersion(t *testing.T) {
|
||||
|
||||
// now we'll restore a post version
|
||||
otherPost := th.CreatePost(th.BasicChannel)
|
||||
restoredPost, appErr := th.App.RestorePostVersion(th.Context, th.BasicUser.Id, post.Id, otherPost.Id)
|
||||
restoredPost, _, appErr := th.App.RestorePostVersion(th.Context, th.BasicUser.Id, post.Id, otherPost.Id)
|
||||
require.NotNil(t, appErr)
|
||||
require.Equal(t, http.StatusBadRequest, appErr.StatusCode)
|
||||
require.Equal(t, "app.post.restore_post_version.not_an_history_item.app_error", appErr.Id)
|
||||
@@ -138,7 +140,7 @@ func TestRestorePostVersion(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("should return an error if the post does not exist", func(t *testing.T) {
|
||||
restoredPost, appErr := th.App.RestorePostVersion(th.Context, th.BasicUser.Id, model.NewId(), model.NewId())
|
||||
restoredPost, _, appErr := th.App.RestorePostVersion(th.Context, th.BasicUser.Id, model.NewId(), model.NewId())
|
||||
require.NotNil(t, appErr)
|
||||
require.Equal(t, http.StatusNotFound, appErr.StatusCode)
|
||||
require.Equal(t, "app.post.restore_post_version.get_single.app_error", appErr.Id)
|
||||
@@ -150,7 +152,7 @@ func TestRestorePostVersion(t *testing.T) {
|
||||
|
||||
// now we'll restore a post version
|
||||
invalidRestorePostIUd := model.NewId()
|
||||
restoredPost, appErr := th.App.RestorePostVersion(th.Context, th.BasicUser.Id, post.Id, invalidRestorePostIUd)
|
||||
restoredPost, _, appErr := th.App.RestorePostVersion(th.Context, th.BasicUser.Id, post.Id, invalidRestorePostIUd)
|
||||
require.NotNil(t, appErr)
|
||||
require.Equal(t, http.StatusNotFound, appErr.StatusCode)
|
||||
require.Equal(t, "app.post.restore_post_version.get_single.app_error", appErr.Id)
|
||||
@@ -172,7 +174,7 @@ func TestRestorePostVersion(t *testing.T) {
|
||||
require.Equal(t, "other post original message", otherPostEditHistory[0].Message)
|
||||
|
||||
// we'll specify post's ID and other post's version ID, his should fail
|
||||
restoredPost, appErr := th.App.RestorePostVersion(th.Context, th.BasicUser.Id, post.Id, otherPostEditHistory[0].Id)
|
||||
restoredPost, _, appErr := th.App.RestorePostVersion(th.Context, th.BasicUser.Id, post.Id, otherPostEditHistory[0].Id)
|
||||
require.NotNil(t, appErr)
|
||||
require.Equal(t, "app.post.restore_post_version.not_an_history_item.app_error", appErr.Id)
|
||||
require.Equal(t, http.StatusBadRequest, appErr.StatusCode)
|
||||
|
||||
Ссылка в новой задаче
Block a user