Files
mostlymatter/server/channels/app/mention_results_test.go
Claudio Costa 611b2a8e79 [MM-62408] Server Code Coverage with Fully Parallel Tests (#30078)
* TestPool

* Store infra

* Store tests updates

* Bump maximum concurrent postgres connections

* More infra

* channels/jobs

* channels/app

* channels/api4

* Protect i18n from concurrent access

* Replace some use of os.Setenv

* Remove debug

* Lint fixes

* Fix more linting

* Fix test

* Remove use of Setenv in drafts tests

* Fix flaky TestWebHubCloseConnOnDBFail

* Fix merge

* [MM-62408] Add CI job to generate test coverage (#30284)

* Add CI job to generate test coverage

* Remove use of Setenv in drafts tests

* Fix flaky TestWebHubCloseConnOnDBFail

* Fix more Setenv usage

* Fix more potential flakyness

* Remove parallelism from flaky test

* Remove conflicting env var

* Fix

* Disable parallelism

* Test atomic covermode

* Disable parallelism

* Enable parallelism

* Add upload coverage step

* Fix codecov.yml

* Add codecov.yml

* Remove redundant workspace field

* Add Parallel() util methods and refactor

* Fix formatting

* More formatting fixes

* Fix reporting
2025-05-30 13:58:26 +02:00

66 строки
1.5 KiB
Go

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
package app
import (
"testing"
"github.com/mattermost/mattermost/server/public/model"
"github.com/stretchr/testify/assert"
)
func TestAddMention(t *testing.T) {
mainHelper.Parallel(t)
t.Run("should initialize Mentions and store new mentions", func(t *testing.T) {
m := &MentionResults{}
userID1 := model.NewId()
userID2 := model.NewId()
m.addMention(userID1, KeywordMention)
m.addMention(userID2, CommentMention)
assert.Equal(t, map[string]MentionType{
userID1: KeywordMention,
userID2: CommentMention,
}, m.Mentions)
})
t.Run("should replace existing mentions with higher priority ones", func(t *testing.T) {
m := &MentionResults{}
userID1 := model.NewId()
userID2 := model.NewId()
m.addMention(userID1, ThreadMention)
m.addMention(userID2, DMMention)
m.addMention(userID1, ChannelMention)
m.addMention(userID2, KeywordMention)
assert.Equal(t, map[string]MentionType{
userID1: ChannelMention,
userID2: KeywordMention,
}, m.Mentions)
})
t.Run("should not replace high priority mentions with low priority ones", func(t *testing.T) {
m := &MentionResults{}
userID1 := model.NewId()
userID2 := model.NewId()
m.addMention(userID1, KeywordMention)
m.addMention(userID2, CommentMention)
m.addMention(userID1, DMMention)
m.addMention(userID2, ThreadMention)
assert.Equal(t, map[string]MentionType{
userID1: KeywordMention,
userID2: CommentMention,
}, m.Mentions)
})
}