MM-13021 Fix warning logged when getting metadata for post without emojis (#9832)

This commit is contained in:
Harrison Healey
2018-11-14 11:54:50 -05:00
committed by Sudheer
parent d07def5169
commit 2113ad0205
2 changed files with 15 additions and 0 deletions

View File

@@ -232,6 +232,10 @@ func (a *App) getCustomEmojisForPost(post *model.Post, reactions []*model.Reacti
names := getEmojiNamesForPost(post, reactions)
if len(names) == 0 {
return []*model.Emoji{}, nil
}
return a.GetMultipleEmojiByName(names)
}

View File

@@ -663,6 +663,17 @@ func TestGetCustomEmojisForPost(t *testing.T) {
assert.Nil(t, err, "failed to get emojis for post")
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) {