Fixed errcheck issues in server/channels/app/notification_test.go (#29068)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
800407f956
Коммит
9ecf9f8ade
@@ -109,7 +109,6 @@ issues:
|
||||
channels/app/job_test.go|\
|
||||
channels/app/login_test.go|\
|
||||
channels/app/migrations.go|\
|
||||
channels/app/notification_test.go|\
|
||||
channels/app/onboarding_test.go|\
|
||||
channels/app/permissions.go|\
|
||||
channels/app/permissions_test.go|\
|
||||
|
||||
@@ -41,7 +41,8 @@ func TestSendNotifications(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.AddUserToChannel(th.Context, th.BasicUser2, th.BasicChannel, false)
|
||||
_, appErr := th.App.AddUserToChannel(th.Context, th.BasicUser2, th.BasicChannel, false)
|
||||
require.Nil(t, appErr)
|
||||
|
||||
post1, createPostErr := th.App.CreatePostMissingChannel(th.Context, &model.Post{
|
||||
UserId: th.BasicUser.Id,
|
||||
@@ -297,7 +298,8 @@ func TestSendNotifications_MentionsFollowers(t *testing.T) {
|
||||
require.Nil(t, appErr)
|
||||
|
||||
defer func() {
|
||||
th.App.UpdateChannelMemberRoles(th.Context, member.ChannelId, member.UserId, originalRoles)
|
||||
_, appErr = th.App.UpdateChannelMemberRoles(th.Context, member.ChannelId, member.UserId, originalRoles)
|
||||
require.Nil(t, appErr)
|
||||
}()
|
||||
|
||||
th.App.Srv().SetLicense(getLicWithSkuShortName(model.LicenseShortSkuEnterprise))
|
||||
@@ -571,7 +573,8 @@ func TestSendNotificationsWithManyUsers(t *testing.T) {
|
||||
for i := 0; i < 10; i++ {
|
||||
user := th.CreateUser()
|
||||
th.LinkUserToTeam(user, th.BasicTeam)
|
||||
th.App.AddUserToChannel(th.Context, user, th.BasicChannel, false)
|
||||
_, appErr := th.App.AddUserToChannel(th.Context, user, th.BasicChannel, false)
|
||||
require.Nil(t, appErr)
|
||||
users = append(users, user)
|
||||
}
|
||||
|
||||
@@ -669,13 +672,19 @@ func TestFilterOutOfChannelMentions(t *testing.T) {
|
||||
guest := th.CreateGuest()
|
||||
user4 := th.CreateUser()
|
||||
guestAndUser4Channel := th.CreateChannel(th.Context, th.BasicTeam)
|
||||
defer th.App.PermanentDeleteUser(th.Context, guest)
|
||||
defer func() {
|
||||
appErr := th.App.PermanentDeleteUser(th.Context, guest)
|
||||
require.Nil(t, appErr)
|
||||
}()
|
||||
th.LinkUserToTeam(user3, th.BasicTeam)
|
||||
th.LinkUserToTeam(user4, th.BasicTeam)
|
||||
th.LinkUserToTeam(guest, th.BasicTeam)
|
||||
th.App.AddUserToChannel(th.Context, guest, channel, false)
|
||||
th.App.AddUserToChannel(th.Context, user4, guestAndUser4Channel, false)
|
||||
th.App.AddUserToChannel(th.Context, guest, guestAndUser4Channel, false)
|
||||
_, appErr := th.App.AddUserToChannel(th.Context, guest, channel, false)
|
||||
require.Nil(t, appErr)
|
||||
_, appErr = th.App.AddUserToChannel(th.Context, user4, guestAndUser4Channel, false)
|
||||
require.Nil(t, appErr)
|
||||
_, appErr = th.App.AddUserToChannel(th.Context, guest, guestAndUser4Channel, false)
|
||||
require.Nil(t, appErr)
|
||||
|
||||
t.Run("should return users not in the channel", func(t *testing.T) {
|
||||
post := &model.Post{}
|
||||
@@ -2524,7 +2533,8 @@ func TestUserAllowsEmail(t *testing.T) {
|
||||
t.Run("should return false in the case user is a bot", func(t *testing.T) {
|
||||
user := th.CreateUser()
|
||||
|
||||
th.App.ConvertUserToBot(th.Context, user)
|
||||
_, appErr := th.App.ConvertUserToBot(th.Context, user)
|
||||
require.Nil(t, appErr)
|
||||
|
||||
channelMemberNotifcationProps := model.StringMap{
|
||||
model.EmailNotifyProp: model.ChannelNotifyDefault,
|
||||
@@ -2549,19 +2559,22 @@ func TestInsertGroupMentions(t *testing.T) {
|
||||
|
||||
groupChannelMember := th.CreateUser()
|
||||
th.LinkUserToTeam(groupChannelMember, team)
|
||||
th.App.AddUserToChannel(th.Context, groupChannelMember, channel, false)
|
||||
_, appErr := th.App.AddUserToChannel(th.Context, groupChannelMember, channel, false)
|
||||
require.Nil(t, appErr)
|
||||
_, err = th.App.UpsertGroupMember(group.Id, groupChannelMember.Id)
|
||||
require.Nil(t, err)
|
||||
|
||||
senderGroupChannelMember := th.CreateUser()
|
||||
th.LinkUserToTeam(senderGroupChannelMember, team)
|
||||
th.App.AddUserToChannel(th.Context, senderGroupChannelMember, channel, false)
|
||||
_, appErr = th.App.AddUserToChannel(th.Context, senderGroupChannelMember, channel, false)
|
||||
require.Nil(t, appErr)
|
||||
_, err = th.App.UpsertGroupMember(group.Id, senderGroupChannelMember.Id)
|
||||
require.Nil(t, err)
|
||||
|
||||
nonGroupChannelMember := th.CreateUser()
|
||||
th.LinkUserToTeam(nonGroupChannelMember, team)
|
||||
th.App.AddUserToChannel(th.Context, nonGroupChannelMember, channel, false)
|
||||
_, appErr = th.App.AddUserToChannel(th.Context, nonGroupChannelMember, channel, false)
|
||||
require.Nil(t, appErr)
|
||||
|
||||
nonChannelGroupMember := th.CreateUser()
|
||||
th.LinkUserToTeam(nonChannelGroupMember, team)
|
||||
@@ -2623,8 +2636,10 @@ func TestInsertGroupMentions(t *testing.T) {
|
||||
|
||||
t.Run("should keep existing mentions", func(t *testing.T) {
|
||||
mentions := &MentionResults{}
|
||||
th.App.insertGroupMentions(senderGroupChannelMember.Id, group, channel, profileMap, mentions)
|
||||
th.App.insertGroupMentions(senderGroupChannelMember.Id, groupWithNoMembers, channel, profileMap, mentions)
|
||||
_, appErr := th.App.insertGroupMentions(senderGroupChannelMember.Id, group, channel, profileMap, mentions)
|
||||
require.Nil(t, appErr)
|
||||
_, appErr = th.App.insertGroupMentions(senderGroupChannelMember.Id, groupWithNoMembers, channel, profileMap, mentions)
|
||||
require.Nil(t, appErr)
|
||||
|
||||
// Ensure mentions from group are kept after running with groupWithNoMembers
|
||||
require.Equal(t, len(mentions.Mentions), 1)
|
||||
@@ -2636,13 +2651,15 @@ func TestInsertGroupMentions(t *testing.T) {
|
||||
emptyProfileMap := make(map[string]*model.User)
|
||||
|
||||
groupChannel := &model.Channel{Type: model.ChannelTypeGroup}
|
||||
usersMentioned, _ := th.App.insertGroupMentions(senderGroupChannelMember.Id, group, groupChannel, emptyProfileMap, mentions)
|
||||
usersMentioned, appErr := th.App.insertGroupMentions(senderGroupChannelMember.Id, group, groupChannel, emptyProfileMap, mentions)
|
||||
require.Nil(t, appErr)
|
||||
// Ensure group channel with no group members mentioned always returns true
|
||||
require.Equal(t, usersMentioned, true)
|
||||
require.Equal(t, len(mentions.Mentions), 0)
|
||||
|
||||
directChannel := &model.Channel{Type: model.ChannelTypeDirect}
|
||||
usersMentioned, _ = th.App.insertGroupMentions(senderGroupChannelMember.Id, group, directChannel, emptyProfileMap, mentions)
|
||||
usersMentioned, appErr = th.App.insertGroupMentions(senderGroupChannelMember.Id, group, directChannel, emptyProfileMap, mentions)
|
||||
require.Nil(t, appErr)
|
||||
// Ensure direct channel with no group members mentioned always returns true
|
||||
require.Equal(t, usersMentioned, true)
|
||||
require.Equal(t, len(mentions.Mentions), 0)
|
||||
@@ -2653,7 +2670,8 @@ func TestInsertGroupMentions(t *testing.T) {
|
||||
require.Nil(t, err)
|
||||
|
||||
mentions := &MentionResults{}
|
||||
th.App.insertGroupMentions(senderGroupChannelMember.Id, group, groupChannel, profileMap, mentions)
|
||||
_, appErr := th.App.insertGroupMentions(senderGroupChannelMember.Id, group, groupChannel, profileMap, mentions)
|
||||
require.Nil(t, appErr)
|
||||
|
||||
require.Equal(t, len(mentions.Mentions), 1)
|
||||
_, found := mentions.Mentions[groupChannelMember.Id]
|
||||
|
||||
Ссылка в новой задаче
Block a user