MM-13021 Fix warning logged when getting metadata for post without emojis (#9832)
Этот коммит содержится в:
коммит произвёл
Sudheer
родитель
d07def5169
Коммит
2113ad0205
@@ -232,6 +232,10 @@ func (a *App) getCustomEmojisForPost(post *model.Post, reactions []*model.Reacti
|
|||||||
|
|
||||||
names := getEmojiNamesForPost(post, reactions)
|
names := getEmojiNamesForPost(post, reactions)
|
||||||
|
|
||||||
|
if len(names) == 0 {
|
||||||
|
return []*model.Emoji{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
return a.GetMultipleEmojiByName(names)
|
return a.GetMultipleEmojiByName(names)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -663,6 +663,17 @@ func TestGetCustomEmojisForPost(t *testing.T) {
|
|||||||
assert.Nil(t, err, "failed to get emojis for post")
|
assert.Nil(t, err, "failed to get emojis for post")
|
||||||
assert.ElementsMatch(t, emojisForPost, []*model.Emoji{emojis[0]}, "received incorrect emojis")
|
assert.ElementsMatch(t, emojisForPost, []*model.Emoji{emojis[0]}, "received incorrect emojis")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
t.Run("with no emojis", func(t *testing.T) {
|
||||||
|
post := &model.Post{
|
||||||
|
Message: "this post is boring",
|
||||||
|
Props: map[string]interface{}{},
|
||||||
|
}
|
||||||
|
|
||||||
|
emojisForPost, err := th.App.getCustomEmojisForPost(post, nil)
|
||||||
|
assert.Nil(t, err, "failed to get emojis for post")
|
||||||
|
assert.ElementsMatch(t, emojisForPost, []*model.Emoji{}, "should have received no emojis")
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetFirstLinkAndImages(t *testing.T) {
|
func TestGetFirstLinkAndImages(t *testing.T) {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user