MM-14897: Changes to be able to add and remove groups from channels. (#10794)
* MM-15162: Changes for LDAP groups removals phase. * MM-14897: Changes to be able to add and remove groups from channels. * Update model/client4.go * MM-14897: PR-requested change to string interpolation.
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
dd33bc13a7
Коммит
1b78f9debc
@@ -466,9 +466,15 @@ func (s *LayeredGroupStore) ChannelMembersToRemove() StoreChannel {
|
||||
})
|
||||
}
|
||||
|
||||
func (s *LayeredGroupStore) GetGroupsByChannel(channelId string, page, perPage int) StoreChannel {
|
||||
func (s *LayeredGroupStore) GetGroupsByChannel(channelId string, opts model.GroupSearchOpts) StoreChannel {
|
||||
return s.RunQuery(func(supplier LayeredStoreSupplier) *LayeredStoreSupplierResult {
|
||||
return supplier.GetGroupsByChannel(s.TmpContext, channelId, page, perPage)
|
||||
return supplier.GetGroupsByChannel(s.TmpContext, channelId, opts)
|
||||
})
|
||||
}
|
||||
|
||||
func (s *LayeredGroupStore) CountGroupsByChannel(channelId string, opts model.GroupSearchOpts) StoreChannel {
|
||||
return s.RunQuery(func(supplier LayeredStoreSupplier) *LayeredStoreSupplierResult {
|
||||
return supplier.CountGroupsByChannel(s.TmpContext, channelId, opts)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -74,8 +74,11 @@ type LayeredStoreSupplier interface {
|
||||
TeamMembersToRemove(ctx context.Context, hints ...LayeredStoreHint) *LayeredStoreSupplierResult
|
||||
ChannelMembersToRemove(ctx context.Context, hints ...LayeredStoreHint) *LayeredStoreSupplierResult
|
||||
|
||||
GetGroupsByChannel(ctx context.Context, channelId string, page, perPage int, hints ...LayeredStoreHint) *LayeredStoreSupplierResult
|
||||
GetGroupsByChannel(ctx context.Context, channelId string, opts model.GroupSearchOpts, hints ...LayeredStoreHint) *LayeredStoreSupplierResult
|
||||
CountGroupsByChannel(ctx context.Context, channelId string, opts model.GroupSearchOpts, hints ...LayeredStoreHint) *LayeredStoreSupplierResult
|
||||
|
||||
GetGroupsByTeam(ctx context.Context, teamId string, opts model.GroupSearchOpts, hints ...LayeredStoreHint) *LayeredStoreSupplierResult
|
||||
CountGroupsByTeam(ctx context.Context, teamId string, opts model.GroupSearchOpts, hints ...LayeredStoreHint) *LayeredStoreSupplierResult
|
||||
|
||||
GetGroups(ctx context.Context, page, perPage int, opts model.GroupSearchOpts, hints ...LayeredStoreHint) *LayeredStoreSupplierResult
|
||||
}
|
||||
|
||||
@@ -109,8 +109,12 @@ func (s *LocalCacheSupplier) ChannelMembersToRemove(ctx context.Context, hints .
|
||||
return s.Next().ChannelMembersToRemove(ctx, hints...)
|
||||
}
|
||||
|
||||
func (s *LocalCacheSupplier) GetGroupsByChannel(ctx context.Context, channelId string, page, perPage int, hints ...LayeredStoreHint) *LayeredStoreSupplierResult {
|
||||
return s.Next().GetGroupsByChannel(ctx, channelId, page, perPage, hints...)
|
||||
func (s *LocalCacheSupplier) GetGroupsByChannel(ctx context.Context, channelId string, opts model.GroupSearchOpts, hints ...LayeredStoreHint) *LayeredStoreSupplierResult {
|
||||
return s.Next().GetGroupsByChannel(ctx, channelId, opts, hints...)
|
||||
}
|
||||
|
||||
func (s *LocalCacheSupplier) CountGroupsByChannel(ctx context.Context, channelId string, opts model.GroupSearchOpts, hints ...LayeredStoreHint) *LayeredStoreSupplierResult {
|
||||
return s.Next().CountGroupsByChannel(ctx, channelId, opts, hints...)
|
||||
}
|
||||
|
||||
func (s *LocalCacheSupplier) GetGroupsByTeam(ctx context.Context, teamId string, opts model.GroupSearchOpts, hints ...LayeredStoreHint) *LayeredStoreSupplierResult {
|
||||
|
||||
@@ -109,9 +109,14 @@ func (s *RedisSupplier) ChannelMembersToRemove(ctx context.Context, hints ...Lay
|
||||
return s.Next().ChannelMembersToRemove(ctx, hints...)
|
||||
}
|
||||
|
||||
func (s *RedisSupplier) GetGroupsByChannel(ctx context.Context, channelId string, page, perPage int, hints ...LayeredStoreHint) *LayeredStoreSupplierResult {
|
||||
func (s *RedisSupplier) GetGroupsByChannel(ctx context.Context, channelId string, opts model.GroupSearchOpts, hints ...LayeredStoreHint) *LayeredStoreSupplierResult {
|
||||
// TODO: Redis caching.
|
||||
return s.Next().GetGroupsByChannel(ctx, channelId, page, perPage, hints...)
|
||||
return s.Next().GetGroupsByChannel(ctx, channelId, opts, hints...)
|
||||
}
|
||||
|
||||
func (s *RedisSupplier) CountGroupsByChannel(ctx context.Context, channelId string, opts model.GroupSearchOpts, hints ...LayeredStoreHint) *LayeredStoreSupplierResult {
|
||||
// TODO: Redis caching.
|
||||
return s.Next().CountGroupsByChannel(ctx, channelId, opts, hints...)
|
||||
}
|
||||
|
||||
func (s *RedisSupplier) GetGroupsByTeam(ctx context.Context, teamId string, opts model.GroupSearchOpts, hints ...LayeredStoreHint) *LayeredStoreSupplierResult {
|
||||
|
||||
@@ -827,32 +827,47 @@ func (s *SqlSupplier) TeamMembersToRemove(ctx context.Context, hints ...store.La
|
||||
return result
|
||||
}
|
||||
|
||||
func (s *SqlSupplier) GetGroupsByChannel(ctx context.Context, channelId string, page, perPage int, hints ...store.LayeredStoreHint) *store.LayeredStoreSupplierResult {
|
||||
func (s *SqlSupplier) CountGroupsByChannel(ctx context.Context, channelId string, opts model.GroupSearchOpts, hints ...store.LayeredStoreHint) *store.LayeredStoreSupplierResult {
|
||||
result := store.NewSupplierResult()
|
||||
|
||||
var groups []*model.Group
|
||||
offset := page * perPage
|
||||
_, err := s.GetReplica().Select(&groups, `
|
||||
SELECT
|
||||
ug.*
|
||||
FROM
|
||||
GroupChannels gc
|
||||
LEFT JOIN
|
||||
UserGroups ug
|
||||
ON
|
||||
gc.GroupId = ug.Id
|
||||
WHERE
|
||||
gc.DeleteAt = 0
|
||||
AND
|
||||
ug.DeleteAt = 0
|
||||
AND
|
||||
gc.ChannelId = :ChannelId
|
||||
ORDER BY
|
||||
ug.DisplayName
|
||||
LIMIT :Limit
|
||||
OFFSET :Offset`,
|
||||
map[string]interface{}{"ChannelId": channelId, "Limit": perPage, "Offset": offset})
|
||||
countQuery := s.groupsBySyncableBaseQuery(model.GroupSyncableTypeChannel, selectCountGroups, channelId, opts)
|
||||
|
||||
countQueryString, args, err := countQuery.ToSql()
|
||||
if err != nil {
|
||||
result.Err = model.NewAppError("SqlGroupStore.CountGroupsByChannel", "store.sql_group.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
return result
|
||||
}
|
||||
|
||||
count, err := s.GetReplica().SelectInt(countQueryString, args...)
|
||||
if err != nil {
|
||||
result.Err = model.NewAppError("SqlGroupStore.CountGroupsByChannel", "store.select_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
return result
|
||||
}
|
||||
|
||||
result.Data = count
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
func (s *SqlSupplier) GetGroupsByChannel(ctx context.Context, channelId string, opts model.GroupSearchOpts, hints ...store.LayeredStoreHint) *store.LayeredStoreSupplierResult {
|
||||
result := store.NewSupplierResult()
|
||||
|
||||
query := s.groupsBySyncableBaseQuery(model.GroupSyncableTypeChannel, selectGroups, channelId, opts)
|
||||
|
||||
if opts.PageOpts != nil {
|
||||
offset := uint64(opts.PageOpts.Page * opts.PageOpts.PerPage)
|
||||
query = query.OrderBy("ug.DisplayName").Limit(uint64(opts.PageOpts.PerPage)).Offset(offset)
|
||||
}
|
||||
|
||||
queryString, args, err := query.ToSql()
|
||||
if err != nil {
|
||||
result.Err = model.NewAppError("SqlGroupStore.GetGroupsByChannel", "store.sql_group.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
return result
|
||||
}
|
||||
|
||||
var groups []*model.Group
|
||||
|
||||
_, err = s.GetReplica().Select(&groups, queryString, args...)
|
||||
if err != nil {
|
||||
result.Err = model.NewAppError("SqlGroupStore.GetGroupsByChannel", "store.select_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
return result
|
||||
@@ -919,25 +934,35 @@ func (s *SqlSupplier) ChannelMembersToRemove(ctx context.Context, hints ...store
|
||||
return result
|
||||
}
|
||||
|
||||
func (s *SqlSupplier) groupsByTeamBaseQuery(t selectType, teamID string, opts model.GroupSearchOpts) squirrel.SelectBuilder {
|
||||
func (s *SqlSupplier) groupsBySyncableBaseQuery(st model.GroupSyncableType, t selectType, syncableID string, opts model.GroupSearchOpts) squirrel.SelectBuilder {
|
||||
selectStrs := map[selectType]string{
|
||||
selectGroups: "ug.*",
|
||||
selectCountGroups: "COUNT(*)",
|
||||
}
|
||||
|
||||
var table string
|
||||
var idCol string
|
||||
if st == model.GroupSyncableTypeTeam {
|
||||
table = "GroupTeams"
|
||||
idCol = "TeamId"
|
||||
} else {
|
||||
table = "GroupChannels"
|
||||
idCol = "ChannelId"
|
||||
}
|
||||
|
||||
query := s.getQueryBuilder().
|
||||
Select(selectStrs[t]).
|
||||
From("GroupTeams gt").
|
||||
LeftJoin("UserGroups ug ON gt.GroupId = ug.Id").
|
||||
Where("ug.DeleteAt = 0 AND gt.TeamId = ? AND gt.DeleteAt = 0", teamID)
|
||||
From(fmt.Sprintf("%s gs", table)).
|
||||
LeftJoin("UserGroups ug ON gs.GroupId = ug.Id").
|
||||
Where(fmt.Sprintf("ug.DeleteAt = 0 AND gs.%s = ? AND gs.DeleteAt = 0", idCol), syncableID)
|
||||
|
||||
if opts.IncludeMemberCount && t == selectGroups {
|
||||
query = s.getQueryBuilder().
|
||||
Select("ug.*, coalesce(Members.MemberCount, 0) AS MemberCount").
|
||||
From("UserGroups ug").
|
||||
LeftJoin("(SELECT GroupMembers.GroupId, COUNT(*) AS MemberCount FROM GroupMembers WHERE GroupMembers.DeleteAt = 0 GROUP BY GroupId) AS Members ON Members.GroupId = ug.Id").
|
||||
LeftJoin("GroupTeams ON GroupTeams.GroupId = ug.Id").
|
||||
Where("GroupTeams.DeleteAt = 0 AND GroupTeams.TeamId = ?", teamID).
|
||||
LeftJoin(fmt.Sprintf("%[1]s ON %[1]s.GroupId = ug.Id", table)).
|
||||
Where(fmt.Sprintf("%[1]s.DeleteAt = 0 AND %[1]s.%[2]s = ?", table, idCol), syncableID).
|
||||
OrderBy("ug.DisplayName")
|
||||
}
|
||||
|
||||
@@ -956,7 +981,7 @@ func (s *SqlSupplier) groupsByTeamBaseQuery(t selectType, teamID string, opts mo
|
||||
func (s *SqlSupplier) CountGroupsByTeam(ctx context.Context, teamId string, opts model.GroupSearchOpts, hints ...store.LayeredStoreHint) *store.LayeredStoreSupplierResult {
|
||||
result := store.NewSupplierResult()
|
||||
|
||||
countQuery := s.groupsByTeamBaseQuery(selectCountGroups, teamId, opts)
|
||||
countQuery := s.groupsBySyncableBaseQuery(model.GroupSyncableTypeTeam, selectCountGroups, teamId, opts)
|
||||
|
||||
countQueryString, args, err := countQuery.ToSql()
|
||||
if err != nil {
|
||||
@@ -978,7 +1003,7 @@ func (s *SqlSupplier) CountGroupsByTeam(ctx context.Context, teamId string, opts
|
||||
func (s *SqlSupplier) GetGroupsByTeam(ctx context.Context, teamId string, opts model.GroupSearchOpts, hints ...store.LayeredStoreHint) *store.LayeredStoreSupplierResult {
|
||||
result := store.NewSupplierResult()
|
||||
|
||||
query := s.groupsByTeamBaseQuery(selectGroups, teamId, opts)
|
||||
query := s.groupsBySyncableBaseQuery(model.GroupSyncableTypeTeam, selectGroups, teamId, opts)
|
||||
|
||||
if opts.PageOpts != nil {
|
||||
offset := uint64(opts.PageOpts.Page * opts.PageOpts.PerPage)
|
||||
@@ -1045,6 +1070,22 @@ func (s *SqlSupplier) GetGroups(ctx context.Context, page, perPage int, opts mod
|
||||
`, opts.NotAssociatedToTeam)
|
||||
}
|
||||
|
||||
if len(opts.NotAssociatedToChannel) == 26 {
|
||||
groupsQuery = groupsQuery.Where(`
|
||||
g.Id NOT IN (
|
||||
SELECT
|
||||
Id
|
||||
FROM
|
||||
UserGroups
|
||||
JOIN GroupChannels ON GroupChannels.GroupId = UserGroups.Id
|
||||
WHERE
|
||||
GroupChannels.DeleteAt = 0
|
||||
AND UserGroups.DeleteAt = 0
|
||||
AND GroupChannels.ChannelId = ?
|
||||
)
|
||||
`, opts.NotAssociatedToChannel)
|
||||
}
|
||||
|
||||
queryString, args, err := groupsQuery.ToSql()
|
||||
if err != nil {
|
||||
result.Err = model.NewAppError("SqlGroupStore.GetGroups", "store.sql_group.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
|
||||
@@ -594,9 +594,12 @@ type GroupStore interface {
|
||||
TeamMembersToRemove() StoreChannel
|
||||
ChannelMembersToRemove() StoreChannel
|
||||
|
||||
GetGroupsByChannel(channelId string, page, perPage int) StoreChannel
|
||||
GetGroupsByChannel(channelId string, opts model.GroupSearchOpts) StoreChannel
|
||||
CountGroupsByChannel(channelId string, opts model.GroupSearchOpts) StoreChannel
|
||||
|
||||
GetGroupsByTeam(teamId string, opts model.GroupSearchOpts) StoreChannel
|
||||
CountGroupsByTeam(teamId string, opts model.GroupSearchOpts) StoreChannel
|
||||
|
||||
GetGroups(page, perPage int, opts model.GroupSearchOpts) StoreChannel
|
||||
}
|
||||
|
||||
|
||||
@@ -1633,23 +1633,44 @@ func testGetGroupsByChannel(t *testing.T, ss store.Store) {
|
||||
})
|
||||
require.Nil(t, res.Err)
|
||||
|
||||
// add members
|
||||
u1 := &model.User{
|
||||
Email: MakeEmail(),
|
||||
Username: model.NewId(),
|
||||
}
|
||||
res = <-ss.User().Save(u1)
|
||||
require.Nil(t, res.Err)
|
||||
user1 := res.Data.(*model.User)
|
||||
<-ss.Group().CreateOrRestoreMember(group1.Id, user1.Id)
|
||||
|
||||
group1WithMemberCount := model.Group(*group1)
|
||||
group1WithMemberCount.MemberCount = model.NewInt(1)
|
||||
|
||||
group2WithMemberCount := model.Group(*group2)
|
||||
group2WithMemberCount.MemberCount = model.NewInt(0)
|
||||
|
||||
testCases := []struct {
|
||||
Name string
|
||||
ChannelId string
|
||||
Page int
|
||||
PerPage int
|
||||
Result []*model.Group
|
||||
Name string
|
||||
ChannelId string
|
||||
Page int
|
||||
PerPage int
|
||||
Result []*model.Group
|
||||
Opts model.GroupSearchOpts
|
||||
TotalCount *int64
|
||||
}{
|
||||
{
|
||||
Name: "Get the two Groups for Channel1",
|
||||
ChannelId: channel1.Id,
|
||||
Page: 0,
|
||||
PerPage: 60,
|
||||
Result: []*model.Group{group1, group2},
|
||||
Name: "Get the two Groups for Channel1",
|
||||
ChannelId: channel1.Id,
|
||||
Opts: model.GroupSearchOpts{},
|
||||
Page: 0,
|
||||
PerPage: 60,
|
||||
Result: []*model.Group{group1, group2},
|
||||
TotalCount: model.NewInt64(2),
|
||||
},
|
||||
{
|
||||
Name: "Get first Group for Channel1 with page 0 with 1 element",
|
||||
ChannelId: channel1.Id,
|
||||
Opts: model.GroupSearchOpts{},
|
||||
Page: 0,
|
||||
PerPage: 1,
|
||||
Result: []*model.Group{group1},
|
||||
@@ -1657,6 +1678,7 @@ func testGetGroupsByChannel(t *testing.T, ss store.Store) {
|
||||
{
|
||||
Name: "Get second Group for Channel1 with page 1 with 1 element",
|
||||
ChannelId: channel1.Id,
|
||||
Opts: model.GroupSearchOpts{},
|
||||
Page: 1,
|
||||
PerPage: 1,
|
||||
Result: []*model.Group{group2},
|
||||
@@ -1664,24 +1686,72 @@ func testGetGroupsByChannel(t *testing.T, ss store.Store) {
|
||||
{
|
||||
Name: "Get third Group for Channel2",
|
||||
ChannelId: channel2.Id,
|
||||
Opts: model.GroupSearchOpts{},
|
||||
Page: 0,
|
||||
PerPage: 60,
|
||||
Result: []*model.Group{group3},
|
||||
},
|
||||
{
|
||||
Name: "Get empty Groups for a fake id",
|
||||
ChannelId: model.NewId(),
|
||||
Name: "Get empty Groups for a fake id",
|
||||
ChannelId: model.NewId(),
|
||||
Opts: model.GroupSearchOpts{},
|
||||
Page: 0,
|
||||
PerPage: 60,
|
||||
Result: []*model.Group{},
|
||||
TotalCount: model.NewInt64(0),
|
||||
},
|
||||
{
|
||||
Name: "Get group matching name",
|
||||
ChannelId: channel1.Id,
|
||||
Opts: model.GroupSearchOpts{Q: string([]rune(group1.Name)[2:10])}, // very low change of a name collision
|
||||
Page: 0,
|
||||
PerPage: 100,
|
||||
Result: []*model.Group{group1},
|
||||
TotalCount: model.NewInt64(1),
|
||||
},
|
||||
{
|
||||
Name: "Get group matching display name",
|
||||
ChannelId: channel1.Id,
|
||||
Opts: model.GroupSearchOpts{Q: "rouP-1"},
|
||||
Page: 0,
|
||||
PerPage: 100,
|
||||
Result: []*model.Group{group1},
|
||||
TotalCount: model.NewInt64(1),
|
||||
},
|
||||
{
|
||||
Name: "Get group matching multiple display names",
|
||||
ChannelId: channel1.Id,
|
||||
Opts: model.GroupSearchOpts{Q: "roUp-"},
|
||||
Page: 0,
|
||||
PerPage: 100,
|
||||
Result: []*model.Group{group1, group2},
|
||||
TotalCount: model.NewInt64(2),
|
||||
},
|
||||
{
|
||||
Name: "Include member counts",
|
||||
ChannelId: channel1.Id,
|
||||
Opts: model.GroupSearchOpts{IncludeMemberCount: true},
|
||||
Page: 0,
|
||||
PerPage: 60,
|
||||
Result: []*model.Group{},
|
||||
PerPage: 2,
|
||||
Result: []*model.Group{&group1WithMemberCount, &group2WithMemberCount},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.Name, func(t *testing.T) {
|
||||
res := <-ss.Group().GetGroupsByChannel(tc.ChannelId, tc.Page, tc.PerPage)
|
||||
if tc.Opts.PageOpts == nil {
|
||||
tc.Opts.PageOpts = &model.PageOpts{}
|
||||
}
|
||||
tc.Opts.PageOpts.Page = tc.Page
|
||||
tc.Opts.PageOpts.PerPage = tc.PerPage
|
||||
res := <-ss.Group().GetGroupsByChannel(tc.ChannelId, tc.Opts)
|
||||
require.Nil(t, res.Err)
|
||||
require.ElementsMatch(t, tc.Result, res.Data.([]*model.Group))
|
||||
if tc.TotalCount != nil {
|
||||
res = <-ss.Group().CountGroupsByChannel(tc.ChannelId, tc.Opts)
|
||||
count := res.Data.(int64)
|
||||
require.Equal(t, *tc.TotalCount, count)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1904,8 +1974,19 @@ func testGetGroups(t *testing.T, ss store.Store) {
|
||||
team1, err := ss.Team().Save(team1)
|
||||
require.Nil(t, err)
|
||||
|
||||
// Create Channel1
|
||||
channel1 := &model.Channel{
|
||||
TeamId: model.NewId(),
|
||||
DisplayName: "Channel1",
|
||||
Name: model.NewId(),
|
||||
Type: model.CHANNEL_PRIVATE,
|
||||
}
|
||||
res := <-ss.Channel().Save(channel1, 9999)
|
||||
require.Nil(t, res.Err)
|
||||
channel1 = res.Data.(*model.Channel)
|
||||
|
||||
// Create Groups 1 and 2
|
||||
res := <-ss.Group().Create(&model.Group{
|
||||
res = <-ss.Group().Create(&model.Group{
|
||||
Name: model.NewId(),
|
||||
DisplayName: "group-1",
|
||||
RemoteId: model.NewId(),
|
||||
@@ -1948,6 +2029,17 @@ func testGetGroups(t *testing.T, ss store.Store) {
|
||||
team2, err = ss.Team().Save(team2)
|
||||
require.Nil(t, err)
|
||||
|
||||
// Create Channel2
|
||||
channel2 := &model.Channel{
|
||||
TeamId: model.NewId(),
|
||||
DisplayName: "Channel2",
|
||||
Name: model.NewId(),
|
||||
Type: model.CHANNEL_PRIVATE,
|
||||
}
|
||||
res = <-ss.Channel().Save(channel2, 9999)
|
||||
require.Nil(t, res.Err)
|
||||
channel2 = res.Data.(*model.Channel)
|
||||
|
||||
// Create Group3
|
||||
res = <-ss.Group().Create(&model.Group{
|
||||
Name: model.NewId(),
|
||||
@@ -1967,6 +2059,26 @@ func testGetGroups(t *testing.T, ss store.Store) {
|
||||
})
|
||||
require.Nil(t, res.Err)
|
||||
|
||||
// And associate Group1 to Channel2
|
||||
res = <-ss.Group().CreateGroupSyncable(&model.GroupSyncable{
|
||||
AutoAdd: true,
|
||||
SyncableId: channel2.Id,
|
||||
Type: model.GroupSyncableTypeChannel,
|
||||
GroupId: group1.Id,
|
||||
})
|
||||
require.Nil(t, res.Err)
|
||||
|
||||
// And associate Group2 and Group3 to Channel1
|
||||
for _, g := range []*model.Group{group2, group3} {
|
||||
res = <-ss.Group().CreateGroupSyncable(&model.GroupSyncable{
|
||||
AutoAdd: true,
|
||||
SyncableId: channel1.Id,
|
||||
Type: model.GroupSyncableTypeChannel,
|
||||
GroupId: g.Id,
|
||||
})
|
||||
require.Nil(t, res.Err)
|
||||
}
|
||||
|
||||
// add members
|
||||
u1 := &model.User{
|
||||
Email: MakeEmail(),
|
||||
@@ -2082,6 +2194,9 @@ func testGetGroups(t *testing.T, ss store.Store) {
|
||||
Page: 0,
|
||||
PerPage: 100,
|
||||
Resultf: func(groups []*model.Group) bool {
|
||||
if len(groups) == 0 {
|
||||
return false
|
||||
}
|
||||
for _, g := range groups {
|
||||
if g.Id == group3.Id {
|
||||
return false
|
||||
@@ -2096,6 +2211,9 @@ func testGetGroups(t *testing.T, ss store.Store) {
|
||||
Page: 0,
|
||||
PerPage: 100,
|
||||
Resultf: func(groups []*model.Group) bool {
|
||||
if len(groups) == 0 {
|
||||
return false
|
||||
}
|
||||
for _, g := range groups {
|
||||
if g.Id == group1.Id || g.Id == group2.Id {
|
||||
return false
|
||||
|
||||
@@ -45,6 +45,22 @@ func (_m *GroupStore) ChannelMembersToRemove() store.StoreChannel {
|
||||
return r0
|
||||
}
|
||||
|
||||
// CountGroupsByChannel provides a mock function with given fields: channelId, opts
|
||||
func (_m *GroupStore) CountGroupsByChannel(channelId string, opts model.GroupSearchOpts) store.StoreChannel {
|
||||
ret := _m.Called(channelId, opts)
|
||||
|
||||
var r0 store.StoreChannel
|
||||
if rf, ok := ret.Get(0).(func(string, model.GroupSearchOpts) store.StoreChannel); ok {
|
||||
r0 = rf(channelId, opts)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(store.StoreChannel)
|
||||
}
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// CountGroupsByTeam provides a mock function with given fields: teamId, opts
|
||||
func (_m *GroupStore) CountGroupsByTeam(teamId string, opts model.GroupSearchOpts) store.StoreChannel {
|
||||
ret := _m.Called(teamId, opts)
|
||||
@@ -253,13 +269,13 @@ func (_m *GroupStore) GetGroups(page int, perPage int, opts model.GroupSearchOpt
|
||||
return r0
|
||||
}
|
||||
|
||||
// GetGroupsByChannel provides a mock function with given fields: channelId, page, perPage
|
||||
func (_m *GroupStore) GetGroupsByChannel(channelId string, page int, perPage int) store.StoreChannel {
|
||||
ret := _m.Called(channelId, page, perPage)
|
||||
// GetGroupsByChannel provides a mock function with given fields: channelId, opts
|
||||
func (_m *GroupStore) GetGroupsByChannel(channelId string, opts model.GroupSearchOpts) store.StoreChannel {
|
||||
ret := _m.Called(channelId, opts)
|
||||
|
||||
var r0 store.StoreChannel
|
||||
if rf, ok := ret.Get(0).(func(string, int, int) store.StoreChannel); ok {
|
||||
r0 = rf(channelId, page, perPage)
|
||||
if rf, ok := ret.Get(0).(func(string, model.GroupSearchOpts) store.StoreChannel); ok {
|
||||
r0 = rf(channelId, opts)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(store.StoreChannel)
|
||||
|
||||
@@ -193,6 +193,29 @@ func (_m *LayeredStoreDatabaseLayer) Compliance() store.ComplianceStore {
|
||||
return r0
|
||||
}
|
||||
|
||||
// CountGroupsByChannel provides a mock function with given fields: ctx, channelId, opts, hints
|
||||
func (_m *LayeredStoreDatabaseLayer) CountGroupsByChannel(ctx context.Context, channelId string, opts model.GroupSearchOpts, hints ...store.LayeredStoreHint) *store.LayeredStoreSupplierResult {
|
||||
_va := make([]interface{}, len(hints))
|
||||
for _i := range hints {
|
||||
_va[_i] = hints[_i]
|
||||
}
|
||||
var _ca []interface{}
|
||||
_ca = append(_ca, ctx, channelId, opts)
|
||||
_ca = append(_ca, _va...)
|
||||
ret := _m.Called(_ca...)
|
||||
|
||||
var r0 *store.LayeredStoreSupplierResult
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string, model.GroupSearchOpts, ...store.LayeredStoreHint) *store.LayeredStoreSupplierResult); ok {
|
||||
r0 = rf(ctx, channelId, opts, hints...)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*store.LayeredStoreSupplierResult)
|
||||
}
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// CountGroupsByTeam provides a mock function with given fields: ctx, teamId, opts, hints
|
||||
func (_m *LayeredStoreDatabaseLayer) CountGroupsByTeam(ctx context.Context, teamId string, opts model.GroupSearchOpts, hints ...store.LayeredStoreHint) *store.LayeredStoreSupplierResult {
|
||||
_va := make([]interface{}, len(hints))
|
||||
@@ -276,20 +299,20 @@ func (_m *LayeredStoreDatabaseLayer) GetGroups(ctx context.Context, page int, pe
|
||||
return r0
|
||||
}
|
||||
|
||||
// GetGroupsByChannel provides a mock function with given fields: ctx, channelId, page, perPage, hints
|
||||
func (_m *LayeredStoreDatabaseLayer) GetGroupsByChannel(ctx context.Context, channelId string, page int, perPage int, hints ...store.LayeredStoreHint) *store.LayeredStoreSupplierResult {
|
||||
// GetGroupsByChannel provides a mock function with given fields: ctx, channelId, opts, hints
|
||||
func (_m *LayeredStoreDatabaseLayer) GetGroupsByChannel(ctx context.Context, channelId string, opts model.GroupSearchOpts, hints ...store.LayeredStoreHint) *store.LayeredStoreSupplierResult {
|
||||
_va := make([]interface{}, len(hints))
|
||||
for _i := range hints {
|
||||
_va[_i] = hints[_i]
|
||||
}
|
||||
var _ca []interface{}
|
||||
_ca = append(_ca, ctx, channelId, page, perPage)
|
||||
_ca = append(_ca, ctx, channelId, opts)
|
||||
_ca = append(_ca, _va...)
|
||||
ret := _m.Called(_ca...)
|
||||
|
||||
var r0 *store.LayeredStoreSupplierResult
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string, int, int, ...store.LayeredStoreHint) *store.LayeredStoreSupplierResult); ok {
|
||||
r0 = rf(ctx, channelId, page, perPage, hints...)
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string, model.GroupSearchOpts, ...store.LayeredStoreHint) *store.LayeredStoreSupplierResult); ok {
|
||||
r0 = rf(ctx, channelId, opts, hints...)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*store.LayeredStoreSupplierResult)
|
||||
|
||||
@@ -60,6 +60,29 @@ func (_m *LayeredStoreSupplier) ChannelMembersToRemove(ctx context.Context, hint
|
||||
return r0
|
||||
}
|
||||
|
||||
// CountGroupsByChannel provides a mock function with given fields: ctx, channelId, opts, hints
|
||||
func (_m *LayeredStoreSupplier) CountGroupsByChannel(ctx context.Context, channelId string, opts model.GroupSearchOpts, hints ...store.LayeredStoreHint) *store.LayeredStoreSupplierResult {
|
||||
_va := make([]interface{}, len(hints))
|
||||
for _i := range hints {
|
||||
_va[_i] = hints[_i]
|
||||
}
|
||||
var _ca []interface{}
|
||||
_ca = append(_ca, ctx, channelId, opts)
|
||||
_ca = append(_ca, _va...)
|
||||
ret := _m.Called(_ca...)
|
||||
|
||||
var r0 *store.LayeredStoreSupplierResult
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string, model.GroupSearchOpts, ...store.LayeredStoreHint) *store.LayeredStoreSupplierResult); ok {
|
||||
r0 = rf(ctx, channelId, opts, hints...)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*store.LayeredStoreSupplierResult)
|
||||
}
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// CountGroupsByTeam provides a mock function with given fields: ctx, teamId, opts, hints
|
||||
func (_m *LayeredStoreSupplier) CountGroupsByTeam(ctx context.Context, teamId string, opts model.GroupSearchOpts, hints ...store.LayeredStoreHint) *store.LayeredStoreSupplierResult {
|
||||
_va := make([]interface{}, len(hints))
|
||||
@@ -106,20 +129,20 @@ func (_m *LayeredStoreSupplier) GetGroups(ctx context.Context, page int, perPage
|
||||
return r0
|
||||
}
|
||||
|
||||
// GetGroupsByChannel provides a mock function with given fields: ctx, channelId, page, perPage, hints
|
||||
func (_m *LayeredStoreSupplier) GetGroupsByChannel(ctx context.Context, channelId string, page int, perPage int, hints ...store.LayeredStoreHint) *store.LayeredStoreSupplierResult {
|
||||
// GetGroupsByChannel provides a mock function with given fields: ctx, channelId, opts, hints
|
||||
func (_m *LayeredStoreSupplier) GetGroupsByChannel(ctx context.Context, channelId string, opts model.GroupSearchOpts, hints ...store.LayeredStoreHint) *store.LayeredStoreSupplierResult {
|
||||
_va := make([]interface{}, len(hints))
|
||||
for _i := range hints {
|
||||
_va[_i] = hints[_i]
|
||||
}
|
||||
var _ca []interface{}
|
||||
_ca = append(_ca, ctx, channelId, page, perPage)
|
||||
_ca = append(_ca, ctx, channelId, opts)
|
||||
_ca = append(_ca, _va...)
|
||||
ret := _m.Called(_ca...)
|
||||
|
||||
var r0 *store.LayeredStoreSupplierResult
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string, int, int, ...store.LayeredStoreHint) *store.LayeredStoreSupplierResult); ok {
|
||||
r0 = rf(ctx, channelId, page, perPage, hints...)
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string, model.GroupSearchOpts, ...store.LayeredStoreHint) *store.LayeredStoreSupplierResult); ok {
|
||||
r0 = rf(ctx, channelId, opts, hints...)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*store.LayeredStoreSupplierResult)
|
||||
|
||||
Ссылка в новой задаче
Block a user