MM-37491: Fix flaky test on file content extraction (#18077)

* MM-37491: Fix flaky test on file content extraction

* Changing Error log to Warn log

* Fix uppercase and dot in the log file

* Simplifiying the test case

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Jesús Espino
2021-08-09 12:32:29 +02:00
коммит произвёл GitHub
родитель 8bfe24c774
Коммит a88702fdaf
2 изменённых файлов: 11 добавлений и 1 удалений

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

@@ -1356,6 +1356,12 @@ func (a *App) ExtractContentFromFileInfo(fileInfo *model.FileInfo) error {
if storeErr := a.Srv().Store.FileInfo().SetContent(fileInfo.Id, text); storeErr != nil {
return errors.Wrap(storeErr, "failed to save the extracted file content")
}
reloadFileInfo, storeErr := a.Srv().Store.FileInfo().Get(fileInfo.Id)
if storeErr != nil {
mlog.Warn("Failed to invalidate the fileInfo cache.", mlog.Err(storeErr), mlog.String("file_info_id", fileInfo.Id))
} else {
a.Srv().Store.FileInfo().InvalidateFileInfosForPostCache(reloadFileInfo.PostId, false)
}
}
return nil
}

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

@@ -189,7 +189,11 @@ func TestPreparePostForClient(t *testing.T) {
fileInfo.PostId = post.Id
clientPost := th.App.PreparePostForClient(post, false, false)
var clientPost *model.Post
assert.Eventually(t, func() bool {
clientPost = th.App.PreparePostForClient(post, false, false)
return assert.ObjectsAreEqual([]*model.FileInfo{fileInfo}, clientPost.Metadata.Files)
}, time.Second, 10*time.Millisecond)
assert.Equal(t, []*model.FileInfo{fileInfo}, clientPost.Metadata.Files, "should've populated Files")
})