mirror of
https://github.com/mattermost/focalboard.git
synced 2025-01-08 15:06:08 +02:00
c8e729b6fe
* refactor: updated dependency for focalboard server * chore: more dependency fixes * refactor: removed the unless code * refactor: added ctx for login and removed unnessary code * refactor: bump up go version * refactor: removed the commented code * chore: upgraded golinter version * fix: linter issue * refactor: removed feature flg fix golinter * refactor: removed feature flag from code * revert: statistic and it's function * refactor: removed ProductLimit related code * refactor: removed isWithinViewsLimit implementation * refactor: moved function GetUsedCardsCount to statistics.go from cloud.go * refactor: removed insight code board * refactor: removed limit dialog * refactor: updated dependencies for linux * chore: golinter fix * chore: updated helper test function to use newLogger * fix: go test * refactor: db ping attempts from config * revert: feature in action * revert: feature flag in action * revert: boardsEditor setting --------- Co-authored-by: Rajat Dabade <rajat@Rajats-MacBook-Pro.local>
53 lines
1.5 KiB
Go
53 lines
1.5 KiB
Go
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
package notifymentions
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
|
|
"github.com/mattermost/focalboard/server/model"
|
|
|
|
mm_model "github.com/mattermost/mattermost/server/public/model"
|
|
)
|
|
|
|
func Test_extractMentions(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
block *model.Block
|
|
want map[string]struct{}
|
|
}{
|
|
{name: "empty", block: makeBlock(""), want: makeMap()},
|
|
{name: "zero mentions", block: makeBlock("This is some text."), want: makeMap()},
|
|
{name: "one mention", block: makeBlock("Hello @user1"), want: makeMap("user1")},
|
|
{name: "multiple mentions", block: makeBlock("Hello @user1, @user2 and @user3"), want: makeMap("user1", "user2", "user3")},
|
|
{name: "include period", block: makeBlock("Hello @user1."), want: makeMap("user1.")},
|
|
{name: "include underscore", block: makeBlock("Hello @user1_"), want: makeMap("user1_")},
|
|
{name: "don't include comma", block: makeBlock("Hello @user1,"), want: makeMap("user1")},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if got := extractMentions(tt.block); !reflect.DeepEqual(got, tt.want) {
|
|
t.Errorf("extractMentions() = %v, want %v", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func makeBlock(text string) *model.Block {
|
|
return &model.Block{
|
|
ID: mm_model.NewId(),
|
|
Type: model.TypeComment,
|
|
Title: text,
|
|
}
|
|
}
|
|
|
|
func makeMap(mentions ...string) map[string]struct{} {
|
|
m := make(map[string]struct{})
|
|
for _, mention := range mentions {
|
|
m[mention] = struct{}{}
|
|
}
|
|
return m
|
|
}
|