[MM-24987] Dont call GetSchemeRolesForChannel and instead load the scheme from channel (#14514)
* MM-24987 Dont call a.GetSchemeRolesForChannel and instead load the scheme using the channel directly * Trigger CI * MM-24987 Add a test for concurrent patch to channel moderation * MM-24987 Cleanup
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
8fe003876d
Коммит
fff93cb73f
@@ -8,6 +8,7 @@ import (
|
||||
"net/http"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -1657,6 +1658,52 @@ func TestPatchChannelModerationsForChannel(t *testing.T) {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
t.Run("Handles concurrent patch requests gracefully", func(t *testing.T) {
|
||||
addCreatePosts := []*model.ChannelModerationPatch{
|
||||
{
|
||||
Name: &createPosts,
|
||||
Roles: &model.ChannelModeratedRolesPatch{
|
||||
Members: model.NewBool(false),
|
||||
Guests: model.NewBool(false),
|
||||
},
|
||||
},
|
||||
}
|
||||
removeCreatePosts := []*model.ChannelModerationPatch{
|
||||
{
|
||||
Name: &createPosts,
|
||||
Roles: &model.ChannelModeratedRolesPatch{
|
||||
Members: model.NewBool(false),
|
||||
Guests: model.NewBool(false),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
wg := sync.WaitGroup{}
|
||||
wg.Add(20)
|
||||
for i := 0; i < 10; i++ {
|
||||
go func() {
|
||||
th.App.PatchChannelModerationsForChannel(channel, addCreatePosts)
|
||||
th.App.PatchChannelModerationsForChannel(channel, removeCreatePosts)
|
||||
wg.Done()
|
||||
}()
|
||||
}
|
||||
for i := 0; i < 10; i++ {
|
||||
go func() {
|
||||
th.App.PatchChannelModerationsForChannel(channel, addCreatePosts)
|
||||
th.App.PatchChannelModerationsForChannel(channel, removeCreatePosts)
|
||||
wg.Done()
|
||||
}()
|
||||
}
|
||||
wg.Wait()
|
||||
|
||||
higherScopedGuestRoleName, higherScopedMemberRoleName, _, _ := th.App.GetTeamSchemeChannelRoles(channel.TeamId)
|
||||
higherScopedMemberRole, _ := th.App.GetRoleByName(higherScopedMemberRoleName)
|
||||
higherScopedGuestRole, _ := th.App.GetRoleByName(higherScopedGuestRoleName)
|
||||
assert.Contains(t, higherScopedMemberRole.Permissions, createPosts)
|
||||
assert.Contains(t, higherScopedGuestRole.Permissions, createPosts)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
// TestMarkChannelsAsViewedPanic verifies that returning an error from a.GetUser
|
||||
|
||||
Ссылка в новой задаче
Block a user