mattermost-community-enterp.../channels/app/mention_results_test.go
Claude ec1f89217a Merge: Complete Mattermost Server with Community Enterprise
Full Mattermost server source with integrated Community Enterprise features.
Includes vendor directory for offline/air-gapped builds.

Structure:
- enterprise-impl/: Enterprise feature implementations
- enterprise-community/: Init files that register implementations
- enterprise/: Bridge imports (community_imports.go)
- vendor/: All dependencies for offline builds

Build (online):
  go build ./cmd/mattermost

Build (offline/air-gapped):
  go build -mod=vendor ./cmd/mattermost

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-17 23:59:07 +09:00

66 lines
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)
})
}