mattermost-community-enterp.../public/model/command_args_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

109 lines
2.3 KiB
Go

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
package model
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestCommandArgs_AddUserMention(t *testing.T) {
fixture := []struct {
args CommandArgs
mentions map[string]string
expected CommandArgs
}{
{
CommandArgs{},
map[string]string{"one": "1"},
CommandArgs{
UserMentions: map[string]string{"one": "1"},
},
},
{
CommandArgs{
ChannelMentions: map[string]string{"channel": "1"},
},
map[string]string{"one": "1"},
CommandArgs{
UserMentions: map[string]string{"one": "1"},
ChannelMentions: map[string]string{"channel": "1"},
},
},
{
CommandArgs{
UserMentions: map[string]string{"one": "1"},
},
map[string]string{"one": "1"},
CommandArgs{
UserMentions: map[string]string{"one": "1"},
},
},
{
CommandArgs{},
map[string]string{"one": "1", "two": "2", "three": "3"},
CommandArgs{
UserMentions: map[string]string{"one": "1", "two": "2", "three": "3"},
},
},
}
for _, data := range fixture {
for name, id := range data.mentions {
data.args.AddUserMention(name, id)
}
require.Equal(t, data.args, data.expected)
}
}
func TestCommandArgs_AddChannelMention(t *testing.T) {
fixture := []struct {
args CommandArgs
mentions map[string]string
expected CommandArgs
}{
{
CommandArgs{},
map[string]string{"one": "1"},
CommandArgs{
ChannelMentions: map[string]string{"one": "1"},
},
},
{
CommandArgs{
UserMentions: map[string]string{"user": "1"},
},
map[string]string{"one": "1"},
CommandArgs{
ChannelMentions: map[string]string{"one": "1"},
UserMentions: map[string]string{"user": "1"},
},
},
{
CommandArgs{
ChannelMentions: map[string]string{"one": "1"},
},
map[string]string{"one": "1"},
CommandArgs{
ChannelMentions: map[string]string{"one": "1"},
},
},
{
CommandArgs{},
map[string]string{"one": "1", "two": "2", "three": "3"},
CommandArgs{
ChannelMentions: map[string]string{"one": "1", "two": "2", "three": "3"},
},
},
}
for _, data := range fixture {
for name, id := range data.mentions {
data.args.AddChannelMention(name, id)
}
require.Equal(t, data.args, data.expected)
}
}