MM-11272 Added initial post metadata (#9175)
* MM-11272 Added app.PreparePostForClient * MM-11272 Added app.PreparePostListForClient * MM-11272 Added EmojiStore.GetMultipleByName * MM-11272 Added emojis to PreparePostForClient * MM-11272 Added unit tests for getting reaction counts * MM-11272 Added unit tests for TestPreparePostForClient * MM-11272 Added emojis from reactions to Post.Emojis * MM-11272 Always update post.UpdateAt when reactions change to bust cache * Fixed merge conflicts * Moved post metadata-related code into its own file * Update store mocks * Fixed typo * Add missing license headers * Updated post metadata tests when custom emojis are disabled * Fix unreliable unit tests * Fix inconsistent casing in SQL statements * Fix blank line * Invalidate store cache after making changes * Clear post cache synchronously with reactions
Этот коммит содержится в:
@@ -82,3 +82,38 @@ func TestReactionIsValid(t *testing.T) {
|
||||
t.Fatal("create at should be invalid")
|
||||
}
|
||||
}
|
||||
|
||||
func TestCountReactions(t *testing.T) {
|
||||
userId := NewId()
|
||||
userId2 := NewId()
|
||||
|
||||
reactions := []*Reaction{
|
||||
{
|
||||
UserId: userId,
|
||||
EmojiName: "smile",
|
||||
},
|
||||
{
|
||||
UserId: userId,
|
||||
EmojiName: "frowning",
|
||||
},
|
||||
{
|
||||
UserId: userId2,
|
||||
EmojiName: "smile",
|
||||
},
|
||||
{
|
||||
UserId: userId2,
|
||||
EmojiName: "neutral_face",
|
||||
},
|
||||
}
|
||||
|
||||
reactionCounts := CountReactions(reactions)
|
||||
if len(reactionCounts) != 3 {
|
||||
t.Fatal("should've received counts for 3 reactions")
|
||||
} else if reactionCounts["smile"] != 2 {
|
||||
t.Fatal("should've received 2 smile reactions")
|
||||
} else if reactionCounts["frowning"] != 1 {
|
||||
t.Fatal("should've received 1 frowning reaction")
|
||||
} else if reactionCounts["neutral_face"] != 1 {
|
||||
t.Fatal("should've received 2 neutral_face reaction")
|
||||
}
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user