Adds the endpoints and store logic to get groups by team and by channel (#10502)
* Adds the endpoints and store logic to get groups by team and by channel * Remove TODO comments * Fix unit tests
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
25fd962016
Коммит
2ce48aa6d1
@@ -477,3 +477,15 @@ func (s *LayeredGroupStore) ChannelMembersToRemove() StoreChannel {
|
||||
return supplier.ChannelMembersToRemove(s.TmpContext)
|
||||
})
|
||||
}
|
||||
|
||||
func (s *LayeredGroupStore) GetGroupsByChannel(channelId string, page, perPage int) StoreChannel {
|
||||
return s.RunQuery(func(supplier LayeredStoreSupplier) *LayeredStoreSupplierResult {
|
||||
return supplier.GetGroupsByChannel(s.TmpContext, channelId, page, perPage)
|
||||
})
|
||||
}
|
||||
|
||||
func (s *LayeredGroupStore) GetGroupsByTeam(teamId string, page, perPage int) StoreChannel {
|
||||
return s.RunQuery(func(supplier LayeredStoreSupplier) *LayeredStoreSupplierResult {
|
||||
return supplier.GetGroupsByTeam(s.TmpContext, teamId, page, perPage)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -73,4 +73,7 @@ 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
|
||||
GetGroupsByTeam(ctx context.Context, teamId string, page, perPage int, hints ...LayeredStoreHint) *LayeredStoreSupplierResult
|
||||
}
|
||||
|
||||
@@ -108,3 +108,11 @@ func (s *LocalCacheSupplier) TeamMembersToRemove(ctx context.Context, hints ...L
|
||||
func (s *LocalCacheSupplier) ChannelMembersToRemove(ctx context.Context, hints ...LayeredStoreHint) *LayeredStoreSupplierResult {
|
||||
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) GetGroupsByTeam(ctx context.Context, teamId string, page, perPage int, hints ...LayeredStoreHint) *LayeredStoreSupplierResult {
|
||||
return s.Next().GetGroupsByTeam(ctx, teamId, page, perPage, hints...)
|
||||
}
|
||||
|
||||
@@ -108,3 +108,13 @@ func (s *RedisSupplier) ChannelMembersToRemove(ctx context.Context, hints ...Lay
|
||||
// TODO: Redis caching.
|
||||
return s.Next().ChannelMembersToRemove(ctx, hints...)
|
||||
}
|
||||
|
||||
func (s *RedisSupplier) GetGroupsByChannel(ctx context.Context, channelId string, page, perPage int, hints ...LayeredStoreHint) *LayeredStoreSupplierResult {
|
||||
// TODO: Redis caching.
|
||||
return s.Next().GetGroupsByChannel(ctx, channelId, page, perPage, hints...)
|
||||
}
|
||||
|
||||
func (s *RedisSupplier) GetGroupsByTeam(ctx context.Context, teamId string, page, perPage int, hints ...LayeredStoreHint) *LayeredStoreSupplierResult {
|
||||
// TODO: Redis caching.
|
||||
return s.Next().GetGroupsByTeam(ctx, teamId, page, perPage, hints...)
|
||||
}
|
||||
|
||||
@@ -222,13 +222,13 @@ func (s *SqlSupplier) GroupGetMemberUsers(stc context.Context, groupID string, h
|
||||
var groupMembers []*model.User
|
||||
|
||||
query := `
|
||||
SELECT
|
||||
Users.*
|
||||
FROM
|
||||
GroupMembers
|
||||
SELECT
|
||||
Users.*
|
||||
FROM
|
||||
GroupMembers
|
||||
JOIN Users ON Users.Id = GroupMembers.UserId
|
||||
WHERE
|
||||
GroupMembers.DeleteAt = 0
|
||||
WHERE
|
||||
GroupMembers.DeleteAt = 0
|
||||
AND Users.DeleteAt = 0
|
||||
AND GroupId = :GroupId`
|
||||
|
||||
@@ -248,13 +248,13 @@ func (s *SqlSupplier) GroupGetMemberUsersPage(stc context.Context, groupID strin
|
||||
var groupMembers []*model.User
|
||||
|
||||
query := `
|
||||
SELECT
|
||||
Users.*
|
||||
FROM
|
||||
GroupMembers
|
||||
SELECT
|
||||
Users.*
|
||||
FROM
|
||||
GroupMembers
|
||||
JOIN Users ON Users.Id = GroupMembers.UserId
|
||||
WHERE
|
||||
GroupMembers.DeleteAt = 0
|
||||
WHERE
|
||||
GroupMembers.DeleteAt = 0
|
||||
AND Users.DeleteAt = 0
|
||||
AND GroupId = :GroupId
|
||||
ORDER BY
|
||||
@@ -281,11 +281,11 @@ func (s *SqlSupplier) GroupGetMemberCount(stc context.Context, groupID string, h
|
||||
var err error
|
||||
|
||||
query := `
|
||||
SELECT
|
||||
count(*)
|
||||
FROM
|
||||
GroupMembers
|
||||
WHERE
|
||||
SELECT
|
||||
count(*)
|
||||
FROM
|
||||
GroupMembers
|
||||
WHERE
|
||||
GroupMembers.GroupId = :GroupId`
|
||||
|
||||
if count, err = s.GetReplica().SelectInt(query, map[string]interface{}{"GroupId": groupID}); err != nil {
|
||||
@@ -506,13 +506,13 @@ func (s *SqlSupplier) GroupGetAllGroupSyncablesByGroup(ctx context.Context, grou
|
||||
case model.GroupSyncableTypeTeam:
|
||||
sqlQuery := `
|
||||
SELECT
|
||||
GroupTeams.*,
|
||||
Teams.DisplayName AS TeamDisplayName,
|
||||
GroupTeams.*,
|
||||
Teams.DisplayName AS TeamDisplayName,
|
||||
Teams.Type AS TeamType
|
||||
FROM
|
||||
FROM
|
||||
GroupTeams
|
||||
JOIN Teams ON Teams.Id = GroupTeams.TeamId
|
||||
WHERE
|
||||
WHERE
|
||||
GroupId = :GroupId AND GroupTeams.DeleteAt = 0`
|
||||
|
||||
results := []*groupTeamJoin{}
|
||||
@@ -538,17 +538,17 @@ func (s *SqlSupplier) GroupGetAllGroupSyncablesByGroup(ctx context.Context, grou
|
||||
case model.GroupSyncableTypeChannel:
|
||||
sqlQuery := `
|
||||
SELECT
|
||||
GroupChannels.*,
|
||||
Channels.DisplayName AS ChannelDisplayName,
|
||||
GroupChannels.*,
|
||||
Channels.DisplayName AS ChannelDisplayName,
|
||||
Teams.DisplayName AS TeamDisplayName,
|
||||
Channels.Type As ChannelType,
|
||||
Teams.Type As TeamType,
|
||||
Teams.Id AS TeamId
|
||||
FROM
|
||||
GroupChannels
|
||||
FROM
|
||||
GroupChannels
|
||||
JOIN Channels ON Channels.Id = GroupChannels.ChannelId
|
||||
JOIN Teams ON Teams.Id = Channels.TeamId
|
||||
WHERE
|
||||
WHERE
|
||||
GroupId = :GroupId AND GroupChannels.DeleteAt = 0`
|
||||
|
||||
results := []*groupChannelJoin{}
|
||||
@@ -676,19 +676,19 @@ func (s *SqlSupplier) TeamMembersToAdd(ctx context.Context, since int64, hints .
|
||||
result := store.NewSupplierResult()
|
||||
|
||||
sql := `
|
||||
SELECT
|
||||
SELECT
|
||||
GroupMembers.UserId, GroupTeams.TeamId
|
||||
FROM
|
||||
FROM
|
||||
GroupMembers
|
||||
JOIN GroupTeams
|
||||
JOIN GroupTeams
|
||||
ON GroupTeams.GroupId = GroupMembers.GroupId
|
||||
JOIN UserGroups ON UserGroups.Id = GroupMembers.GroupId
|
||||
JOIN Teams ON Teams.Id = GroupTeams.TeamId
|
||||
LEFT OUTER JOIN TeamMembers
|
||||
ON
|
||||
TeamMembers.TeamId = GroupTeams.TeamId
|
||||
LEFT OUTER JOIN TeamMembers
|
||||
ON
|
||||
TeamMembers.TeamId = GroupTeams.TeamId
|
||||
AND TeamMembers.UserId = GroupMembers.UserId
|
||||
WHERE
|
||||
WHERE
|
||||
TeamMembers.UserId IS NULL
|
||||
AND UserGroups.DeleteAt = 0
|
||||
AND GroupTeams.DeleteAt = 0
|
||||
@@ -718,16 +718,16 @@ func (s *SqlSupplier) ChannelMembersToAdd(ctx context.Context, since int64, hint
|
||||
result := store.NewSupplierResult()
|
||||
|
||||
sql := `
|
||||
SELECT
|
||||
SELECT
|
||||
GroupMembers.UserId, GroupChannels.ChannelId
|
||||
FROM
|
||||
FROM
|
||||
GroupMembers
|
||||
JOIN GroupChannels ON GroupChannels.GroupId = GroupMembers.GroupId
|
||||
JOIN UserGroups ON UserGroups.Id = GroupMembers.GroupId
|
||||
JOIN Channels ON Channels.Id = GroupChannels.ChannelId
|
||||
LEFT OUTER JOIN ChannelMemberHistory
|
||||
ON
|
||||
ChannelMemberHistory.ChannelId = GroupChannels.ChannelId
|
||||
LEFT OUTER JOIN ChannelMemberHistory
|
||||
ON
|
||||
ChannelMemberHistory.ChannelId = GroupChannels.ChannelId
|
||||
AND ChannelMemberHistory.UserId = GroupMembers.UserId
|
||||
WHERE
|
||||
ChannelMemberHistory.UserId IS NULL
|
||||
@@ -811,6 +811,40 @@ 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 {
|
||||
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
|
||||
ug.DeleteAt = 0
|
||||
AND
|
||||
gc.ChannelId = :ChannelId
|
||||
ORDER BY
|
||||
ug.DisplayName
|
||||
LIMIT :Limit
|
||||
OFFSET :Offset`,
|
||||
map[string]interface{}{"ChannelId": channelId, "Limit": perPage, "Offset": offset})
|
||||
|
||||
if err != nil {
|
||||
result.Err = model.NewAppError("SqlGroupStore.GetGroupsByChannel", "store.select_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
return result
|
||||
}
|
||||
|
||||
result.Data = groups
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
// ChannelMembersToRemove returns all channel members that should be removed based on group constraints.
|
||||
func (s *SqlSupplier) ChannelMembersToRemove(ctx context.Context, hints ...store.LayeredStoreHint) *store.LayeredStoreSupplierResult {
|
||||
result := store.NewSupplierResult()
|
||||
@@ -854,3 +888,37 @@ func (s *SqlSupplier) ChannelMembersToRemove(ctx context.Context, hints ...store
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
func (s *SqlSupplier) GetGroupsByTeam(ctx context.Context, teamId string, page, perPage int, hints ...store.LayeredStoreHint) *store.LayeredStoreSupplierResult {
|
||||
result := store.NewSupplierResult()
|
||||
|
||||
var groups []*model.Group
|
||||
offset := page * perPage
|
||||
_, err := s.GetReplica().Select(&groups, `
|
||||
SELECT
|
||||
ug.*
|
||||
FROM
|
||||
GroupTeams gt
|
||||
LEFT JOIN
|
||||
UserGroups ug
|
||||
ON
|
||||
gt.GroupId = ug.Id
|
||||
WHERE
|
||||
ug.DeleteAt = 0
|
||||
AND
|
||||
gt.TeamId = :TeamId
|
||||
ORDER BY
|
||||
ug.DisplayName
|
||||
LIMIT :Limit
|
||||
OFFSET :Offset`,
|
||||
map[string]interface{}{"TeamId": teamId, "Limit": perPage, "Offset": offset})
|
||||
|
||||
if err != nil {
|
||||
result.Err = model.NewAppError("SqlGroupStore.GetGroupsByTeam", "store.select_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
return result
|
||||
}
|
||||
|
||||
result.Data = groups
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -585,6 +585,9 @@ type GroupStore interface {
|
||||
|
||||
TeamMembersToRemove() StoreChannel
|
||||
ChannelMembersToRemove() StoreChannel
|
||||
|
||||
GetGroupsByChannel(channelId string, page, perPage int) StoreChannel
|
||||
GetGroupsByTeam(teamId string, page, perPage int) StoreChannel
|
||||
}
|
||||
|
||||
type LinkMetadataStore interface {
|
||||
|
||||
@@ -36,6 +36,9 @@ func TestGroupStore(t *testing.T, ss store.Store) {
|
||||
|
||||
t.Run("TeamMembersToRemove", func(t *testing.T) { testPendingTeamMemberRemovals(t, ss) })
|
||||
t.Run("ChannelMembersToRemove", func(t *testing.T) { testPendingChannelMemberRemovals(t, ss) })
|
||||
|
||||
t.Run("GetGroupsByChannel", func(t *testing.T) { testGetGroupsByChannel(t, ss) })
|
||||
t.Run("GetGroupsByTeam", func(t *testing.T) { testGetGroupsByTeam(t, ss) })
|
||||
}
|
||||
|
||||
func testGroupStoreCreate(t *testing.T, ss store.Store) {
|
||||
@@ -1507,3 +1510,261 @@ func pendingMemberRemovalsDataSetup(t *testing.T, ss store.Store) *removalsData
|
||||
Group: group,
|
||||
}
|
||||
}
|
||||
|
||||
func testGetGroupsByChannel(t *testing.T, ss store.Store) {
|
||||
// Create Channel1
|
||||
channel1 := &model.Channel{
|
||||
TeamId: model.NewId(),
|
||||
DisplayName: "Channel1",
|
||||
Name: model.NewId(),
|
||||
Type: model.CHANNEL_OPEN,
|
||||
}
|
||||
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{
|
||||
Name: model.NewId(),
|
||||
DisplayName: "group-1",
|
||||
RemoteId: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
})
|
||||
require.Nil(t, res.Err)
|
||||
group1 := res.Data.(*model.Group)
|
||||
|
||||
res = <-ss.Group().Create(&model.Group{
|
||||
Name: model.NewId(),
|
||||
DisplayName: "group-2",
|
||||
RemoteId: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
})
|
||||
require.Nil(t, res.Err)
|
||||
group2 := res.Data.(*model.Group)
|
||||
|
||||
// And associate them with Channel1
|
||||
for _, g := range []*model.Group{group1, group2} {
|
||||
res = <-ss.Group().CreateGroupSyncable(&model.GroupSyncable{
|
||||
AutoAdd: true,
|
||||
SyncableId: channel1.Id,
|
||||
Type: model.GroupSyncableTypeChannel,
|
||||
GroupId: g.Id,
|
||||
})
|
||||
require.Nil(t, res.Err)
|
||||
}
|
||||
|
||||
// Create Channel2
|
||||
channel2 := &model.Channel{
|
||||
TeamId: model.NewId(),
|
||||
DisplayName: "Channel2",
|
||||
Name: model.NewId(),
|
||||
Type: model.CHANNEL_OPEN,
|
||||
}
|
||||
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(),
|
||||
DisplayName: "group-3",
|
||||
RemoteId: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
})
|
||||
require.Nil(t, res.Err)
|
||||
group3 := res.Data.(*model.Group)
|
||||
|
||||
// And associate it to Channel2
|
||||
res = <-ss.Group().CreateGroupSyncable(&model.GroupSyncable{
|
||||
AutoAdd: true,
|
||||
SyncableId: channel2.Id,
|
||||
Type: model.GroupSyncableTypeChannel,
|
||||
GroupId: group3.Id,
|
||||
})
|
||||
require.Nil(t, res.Err)
|
||||
|
||||
testCases := []struct {
|
||||
Name string
|
||||
ChannelId string
|
||||
Page int
|
||||
PerPage int
|
||||
Result []*model.Group
|
||||
}{
|
||||
{
|
||||
Name: "Get the two Groups for Channel1",
|
||||
ChannelId: channel1.Id,
|
||||
Page: 0,
|
||||
PerPage: 60,
|
||||
Result: []*model.Group{group1, group2},
|
||||
},
|
||||
{
|
||||
Name: "Get first Group for Channel1 with page 0 with 1 element",
|
||||
ChannelId: channel1.Id,
|
||||
Page: 0,
|
||||
PerPage: 1,
|
||||
Result: []*model.Group{group1},
|
||||
},
|
||||
{
|
||||
Name: "Get second Group for Channel1 with page 1 with 1 element",
|
||||
ChannelId: channel1.Id,
|
||||
Page: 1,
|
||||
PerPage: 1,
|
||||
Result: []*model.Group{group2},
|
||||
},
|
||||
{
|
||||
Name: "Get third Group for Channel2",
|
||||
ChannelId: channel2.Id,
|
||||
Page: 0,
|
||||
PerPage: 60,
|
||||
Result: []*model.Group{group3},
|
||||
},
|
||||
{
|
||||
Name: "Get empty Groups for a fake id",
|
||||
ChannelId: model.NewId(),
|
||||
Page: 0,
|
||||
PerPage: 60,
|
||||
Result: []*model.Group{},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.Name, func(t *testing.T) {
|
||||
res := <-ss.Group().GetGroupsByChannel(tc.ChannelId, tc.Page, tc.PerPage)
|
||||
require.Nil(t, res.Err)
|
||||
require.ElementsMatch(t, tc.Result, res.Data.([]*model.Group))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func testGetGroupsByTeam(t *testing.T, ss store.Store) {
|
||||
// Create Team1
|
||||
team1 := &model.Team{
|
||||
DisplayName: "Team1",
|
||||
Description: model.NewId(),
|
||||
CompanyName: model.NewId(),
|
||||
AllowOpenInvite: false,
|
||||
InviteId: model.NewId(),
|
||||
Name: model.NewId(),
|
||||
Email: "success+" + model.NewId() + "@simulator.amazonses.com",
|
||||
Type: model.TEAM_OPEN,
|
||||
}
|
||||
res := <-ss.Team().Save(team1)
|
||||
require.Nil(t, res.Err)
|
||||
team1 = res.Data.(*model.Team)
|
||||
|
||||
// Create Groups 1 and 2
|
||||
res = <-ss.Group().Create(&model.Group{
|
||||
Name: model.NewId(),
|
||||
DisplayName: "group-1",
|
||||
RemoteId: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
})
|
||||
require.Nil(t, res.Err)
|
||||
group1 := res.Data.(*model.Group)
|
||||
|
||||
res = <-ss.Group().Create(&model.Group{
|
||||
Name: model.NewId(),
|
||||
DisplayName: "group-2",
|
||||
RemoteId: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
})
|
||||
require.Nil(t, res.Err)
|
||||
group2 := res.Data.(*model.Group)
|
||||
|
||||
// And associate them with Team1
|
||||
for _, g := range []*model.Group{group1, group2} {
|
||||
res = <-ss.Group().CreateGroupSyncable(&model.GroupSyncable{
|
||||
AutoAdd: true,
|
||||
SyncableId: team1.Id,
|
||||
Type: model.GroupSyncableTypeTeam,
|
||||
GroupId: g.Id,
|
||||
})
|
||||
require.Nil(t, res.Err)
|
||||
}
|
||||
|
||||
// Create Team2
|
||||
team2 := &model.Team{
|
||||
DisplayName: "Team2",
|
||||
Description: model.NewId(),
|
||||
CompanyName: model.NewId(),
|
||||
AllowOpenInvite: false,
|
||||
InviteId: model.NewId(),
|
||||
Name: model.NewId(),
|
||||
Email: "success+" + model.NewId() + "@simulator.amazonses.com",
|
||||
Type: model.TEAM_INVITE,
|
||||
}
|
||||
res = <-ss.Team().Save(team2)
|
||||
require.Nil(t, res.Err)
|
||||
team2 = res.Data.(*model.Team)
|
||||
|
||||
// Create Group3
|
||||
res = <-ss.Group().Create(&model.Group{
|
||||
Name: model.NewId(),
|
||||
DisplayName: "group-3",
|
||||
RemoteId: model.NewId(),
|
||||
Source: model.GroupSourceLdap,
|
||||
})
|
||||
require.Nil(t, res.Err)
|
||||
group3 := res.Data.(*model.Group)
|
||||
|
||||
// And associate it to Team2
|
||||
res = <-ss.Group().CreateGroupSyncable(&model.GroupSyncable{
|
||||
AutoAdd: true,
|
||||
SyncableId: team2.Id,
|
||||
Type: model.GroupSyncableTypeTeam,
|
||||
GroupId: group3.Id,
|
||||
})
|
||||
require.Nil(t, res.Err)
|
||||
|
||||
testCases := []struct {
|
||||
Name string
|
||||
TeamId string
|
||||
Page int
|
||||
PerPage int
|
||||
Result []*model.Group
|
||||
}{
|
||||
{
|
||||
Name: "Get the two Groups for Team1",
|
||||
TeamId: team1.Id,
|
||||
Page: 0,
|
||||
PerPage: 60,
|
||||
Result: []*model.Group{group1, group2},
|
||||
},
|
||||
{
|
||||
Name: "Get first Group for Team1 with page 0 with 1 element",
|
||||
TeamId: team1.Id,
|
||||
Page: 0,
|
||||
PerPage: 1,
|
||||
Result: []*model.Group{group1},
|
||||
},
|
||||
{
|
||||
Name: "Get second Group for Team1 with page 1 with 1 element",
|
||||
TeamId: team1.Id,
|
||||
Page: 1,
|
||||
PerPage: 1,
|
||||
Result: []*model.Group{group2},
|
||||
},
|
||||
{
|
||||
Name: "Get third Group for Team2",
|
||||
TeamId: team2.Id,
|
||||
Page: 0,
|
||||
PerPage: 60,
|
||||
Result: []*model.Group{group3},
|
||||
},
|
||||
{
|
||||
Name: "Get empty Groups for a fake id",
|
||||
TeamId: model.NewId(),
|
||||
Page: 0,
|
||||
PerPage: 60,
|
||||
Result: []*model.Group{},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.Name, func(t *testing.T) {
|
||||
res := <-ss.Group().GetGroupsByTeam(tc.TeamId, tc.Page, tc.PerPage)
|
||||
require.Nil(t, res.Err)
|
||||
require.ElementsMatch(t, tc.Result, res.Data.([]*model.Group))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,6 +189,38 @@ func (_m *GroupStore) GetGroupSyncable(groupID string, syncableID string, syncab
|
||||
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)
|
||||
|
||||
var r0 store.StoreChannel
|
||||
if rf, ok := ret.Get(0).(func(string, int, int) store.StoreChannel); ok {
|
||||
r0 = rf(channelId, page, perPage)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(store.StoreChannel)
|
||||
}
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// GetGroupsByTeam provides a mock function with given fields: teamId, page, perPage
|
||||
func (_m *GroupStore) GetGroupsByTeam(teamId string, page int, perPage int) store.StoreChannel {
|
||||
ret := _m.Called(teamId, page, perPage)
|
||||
|
||||
var r0 store.StoreChannel
|
||||
if rf, ok := ret.Get(0).(func(string, int, int) store.StoreChannel); ok {
|
||||
r0 = rf(teamId, page, perPage)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(store.StoreChannel)
|
||||
}
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// GetMemberCount provides a mock function with given fields: groupID
|
||||
func (_m *GroupStore) GetMemberCount(groupID string) store.StoreChannel {
|
||||
ret := _m.Called(groupID)
|
||||
|
||||
@@ -184,6 +184,52 @@ func (_m *LayeredStoreDatabaseLayer) FileInfo() store.FileInfoStore {
|
||||
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 {
|
||||
_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, _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...)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*store.LayeredStoreSupplierResult)
|
||||
}
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// GetGroupsByTeam provides a mock function with given fields: ctx, teamId, page, perPage, hints
|
||||
func (_m *LayeredStoreDatabaseLayer) GetGroupsByTeam(ctx context.Context, teamId string, page int, perPage int, 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, teamId, page, perPage)
|
||||
_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, teamId, page, perPage, hints...)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*store.LayeredStoreSupplierResult)
|
||||
}
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// Group provides a mock function with given fields:
|
||||
func (_m *LayeredStoreDatabaseLayer) Group() store.GroupStore {
|
||||
ret := _m.Called()
|
||||
|
||||
@@ -14,6 +14,52 @@ type LayeredStoreSupplier struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
// 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 {
|
||||
_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, _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...)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*store.LayeredStoreSupplierResult)
|
||||
}
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// GetGroupsByTeam provides a mock function with given fields: ctx, teamId, page, perPage, hints
|
||||
func (_m *LayeredStoreSupplier) GetGroupsByTeam(ctx context.Context, teamId string, page int, perPage int, 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, teamId, page, perPage)
|
||||
_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, teamId, page, perPage, hints...)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*store.LayeredStoreSupplierResult)
|
||||
}
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// GroupCreate provides a mock function with given fields: ctx, group, hints
|
||||
func (_m *LayeredStoreSupplier) GroupCreate(ctx context.Context, group *model.Group, hints ...store.LayeredStoreHint) *store.LayeredStoreSupplierResult {
|
||||
_va := make([]interface{}, len(hints))
|
||||
|
||||
Ссылка в новой задаче
Block a user