Migrate FileInfo store to Sync by default (#10837)

Этот коммит содержится в:
Jesús Espino
2019-05-15 22:07:03 +02:00
коммит произвёл GitHub
родитель 99ea780f20
Коммит beb7592c93
17 изменённых файлов: 462 добавлений и 459 удалений

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

@@ -20,9 +20,9 @@ import (
"github.com/mattermost/mattermost-server/app"
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/store"
"github.com/mattermost/mattermost-server/utils/fileutils"
"github.com/mattermost/mattermost-server/utils/testutils"
"github.com/stretchr/testify/require"
)
var testDir = ""
@@ -680,13 +680,8 @@ func TestUploadFiles(t *testing.T) {
fmt.Sprintf("Wrong clientId returned, expected %v, got %v", tc.clientIds[i], fileResp.ClientIds[i]))
}
var dbInfo *model.FileInfo
result := <-th.App.Srv.Store.FileInfo().Get(ri.Id)
if result.Err != nil {
t.Error(result.Err)
} else {
dbInfo = result.Data.(*model.FileInfo)
}
dbInfo, err := th.App.Srv.Store.FileInfo().Get(ri.Id)
require.Nil(t, err)
checkEq(t, dbInfo.Id, ri.Id, "File id from response should match one stored in database")
checkEq(t, dbInfo.CreatorId, tc.expectedCreatorId, "F ile should be assigned to user")
checkEq(t, dbInfo.PostId, "", "File shouldn't have a post")
@@ -957,7 +952,8 @@ func TestGetFileLink(t *testing.T) {
CheckBadRequestStatus(t, resp)
// Hacky way to assign file to a post (usually would be done by CreatePost call)
store.Must(th.App.Srv.Store.FileInfo().AttachToPost(fileId, th.BasicPost.Id, th.BasicUser.Id))
err := th.App.Srv.Store.FileInfo().AttachToPost(fileId, th.BasicPost.Id, th.BasicUser.Id)
require.Nil(t, err)
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.FileSettings.EnablePublicLink = false })
_, resp = Client.GetFileLink(fileId)
@@ -993,11 +989,9 @@ func TestGetFileLink(t *testing.T) {
_, resp = th.SystemAdminClient.GetFileLink(fileId)
CheckNoError(t, resp)
if result := <-th.App.Srv.Store.FileInfo().Get(fileId); result.Err != nil {
t.Fatal(result.Err)
} else {
th.cleanupTestFile(result.Data.(*model.FileInfo))
}
fileInfo, err := th.App.Srv.Store.FileInfo().Get(fileId)
require.Nil(t, err)
th.cleanupTestFile(fileInfo)
}
func TestGetFilePreview(t *testing.T) {
@@ -1139,10 +1133,11 @@ func TestGetPublicFile(t *testing.T) {
}
// Hacky way to assign file to a post (usually would be done by CreatePost call)
store.Must(th.App.Srv.Store.FileInfo().AttachToPost(fileId, th.BasicPost.Id, th.BasicUser.Id))
err := th.App.Srv.Store.FileInfo().AttachToPost(fileId, th.BasicPost.Id, th.BasicUser.Id)
require.Nil(t, err)
result := <-th.App.Srv.Store.FileInfo().Get(fileId)
info := result.Data.(*model.FileInfo)
info, err := th.App.Srv.Store.FileInfo().Get(fileId)
require.Nil(t, err)
link := th.App.GeneratePublicLink(Client.Url, info)
// Wait a bit for files to ready
@@ -1174,9 +1169,8 @@ func TestGetPublicFile(t *testing.T) {
t.Fatal("should've failed to get image with public link after salt changed")
}
if err := th.cleanupTestFile(store.Must(th.App.Srv.Store.FileInfo().Get(fileId)).(*model.FileInfo)); err != nil {
t.Fatal(err)
}
fileInfo, err := th.App.Srv.Store.FileInfo().Get(fileId)
require.Nil(t, err)
require.Nil(t, th.cleanupTestFile(fileInfo))
th.cleanupTestFile(info)
}