MM-23596: Ability to list private channels for team (#14925)
Summary: store, app, api and go driver support for listing private channels Ticket Link: https://mattermost.atlassian.net/browse/MM-23596
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
a4fc0fcfb7
Коммит
af8b914c6c
@@ -61,6 +61,7 @@ func TestChannelStore(t *testing.T, ss store.Store, s SqlSupplier) {
|
||||
t.Run("GetChannels", func(t *testing.T) { testChannelStoreGetChannels(t, ss) })
|
||||
t.Run("GetAllChannels", func(t *testing.T) { testChannelStoreGetAllChannels(t, ss, s) })
|
||||
t.Run("GetMoreChannels", func(t *testing.T) { testChannelStoreGetMoreChannels(t, ss) })
|
||||
t.Run("GetPrivateChannelsForTeam", func(t *testing.T) { testChannelStoreGetPrivateChannelsForTeam(t, ss) })
|
||||
t.Run("GetPublicChannelsForTeam", func(t *testing.T) { testChannelStoreGetPublicChannelsForTeam(t, ss) })
|
||||
t.Run("GetPublicChannelsByIdsForTeam", func(t *testing.T) { testChannelStoreGetPublicChannelsByIdsForTeam(t, ss) })
|
||||
t.Run("GetChannelCounts", func(t *testing.T) { testChannelStoreGetChannelCounts(t, ss) })
|
||||
@@ -3444,6 +3445,98 @@ func testChannelStoreGetMoreChannels(t *testing.T, ss store.Store) {
|
||||
})
|
||||
}
|
||||
|
||||
func testChannelStoreGetPrivateChannelsForTeam(t *testing.T, ss store.Store) {
|
||||
teamId := model.NewId()
|
||||
|
||||
// p1 is a private channel on the team
|
||||
p1 := model.Channel{
|
||||
TeamId: teamId,
|
||||
DisplayName: "PrivateChannel1Team1",
|
||||
Name: "zz" + model.NewId() + "b",
|
||||
Type: model.CHANNEL_PRIVATE,
|
||||
}
|
||||
_, nErr := ss.Channel().Save(&p1, -1)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
// p2 is a private channel on another team
|
||||
p2 := model.Channel{
|
||||
TeamId: model.NewId(),
|
||||
DisplayName: "PrivateChannel1Team2",
|
||||
Name: "zz" + model.NewId() + "b",
|
||||
Type: model.CHANNEL_PRIVATE,
|
||||
}
|
||||
_, nErr = ss.Channel().Save(&p2, -1)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
// o1 is a public channel on the team
|
||||
o1 := model.Channel{
|
||||
TeamId: teamId,
|
||||
DisplayName: "OpenChannel1Team1",
|
||||
Name: "zz" + model.NewId() + "b",
|
||||
Type: model.CHANNEL_OPEN,
|
||||
}
|
||||
_, nErr = ss.Channel().Save(&o1, -1)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
t.Run("only p1 initially listed in private channels", func(t *testing.T) {
|
||||
list, channelErr := ss.Channel().GetPrivateChannelsForTeam(teamId, 0, 100)
|
||||
require.Nil(t, channelErr)
|
||||
require.Equal(t, &model.ChannelList{&p1}, list)
|
||||
})
|
||||
|
||||
// p3 is another private channel on the team
|
||||
p3 := model.Channel{
|
||||
TeamId: teamId,
|
||||
DisplayName: "PrivateChannel2Team1",
|
||||
Name: "zz" + model.NewId() + "b",
|
||||
Type: model.CHANNEL_PRIVATE,
|
||||
}
|
||||
_, nErr = ss.Channel().Save(&p3, -1)
|
||||
require.Nil(t, nErr)
|
||||
|
||||
// p4 is another private, but deleted channel on the team
|
||||
p4 := model.Channel{
|
||||
TeamId: teamId,
|
||||
DisplayName: "PrivateChannel3Team1",
|
||||
Name: "zz" + model.NewId() + "b",
|
||||
Type: model.CHANNEL_PRIVATE,
|
||||
}
|
||||
_, nErr = ss.Channel().Save(&p4, -1)
|
||||
require.Nil(t, nErr)
|
||||
err := ss.Channel().Delete(p4.Id, model.GetMillis())
|
||||
require.Nil(t, err, "channel should have been deleted")
|
||||
|
||||
t.Run("both p1 and p3 listed in private channels", func(t *testing.T) {
|
||||
list, err := ss.Channel().GetPrivateChannelsForTeam(teamId, 0, 100)
|
||||
require.Nil(t, err)
|
||||
require.Equal(t, &model.ChannelList{&p1, &p3}, list)
|
||||
})
|
||||
|
||||
t.Run("only p1 listed in private channels with offset 0, limit 1", func(t *testing.T) {
|
||||
list, err := ss.Channel().GetPrivateChannelsForTeam(teamId, 0, 1)
|
||||
require.Nil(t, err)
|
||||
require.Equal(t, &model.ChannelList{&p1}, list)
|
||||
})
|
||||
|
||||
t.Run("only p3 listed in private channels with offset 1, limit 1", func(t *testing.T) {
|
||||
list, err := ss.Channel().GetPrivateChannelsForTeam(teamId, 1, 1)
|
||||
require.Nil(t, err)
|
||||
require.Equal(t, &model.ChannelList{&p3}, list)
|
||||
})
|
||||
|
||||
t.Run("verify analytics for private channels", func(t *testing.T) {
|
||||
count, err := ss.Channel().AnalyticsTypeCount(teamId, model.CHANNEL_PRIVATE)
|
||||
require.Nil(t, err)
|
||||
require.EqualValues(t, 3, count)
|
||||
})
|
||||
|
||||
t.Run("verify analytics for open open channels", func(t *testing.T) {
|
||||
count, err := ss.Channel().AnalyticsTypeCount(teamId, model.CHANNEL_OPEN)
|
||||
require.Nil(t, err)
|
||||
require.EqualValues(t, 1, count)
|
||||
})
|
||||
}
|
||||
|
||||
func testChannelStoreGetPublicChannelsForTeam(t *testing.T, ss store.Store) {
|
||||
teamId := model.NewId()
|
||||
|
||||
|
||||
@@ -1051,6 +1051,31 @@ func (_m *ChannelStore) GetPinnedPosts(channelId string) (*model.PostList, *mode
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetPrivateChannelsForTeam provides a mock function with given fields: teamId, offset, limit
|
||||
func (_m *ChannelStore) GetPrivateChannelsForTeam(teamId string, offset int, limit int) (*model.ChannelList, *model.AppError) {
|
||||
ret := _m.Called(teamId, offset, limit)
|
||||
|
||||
var r0 *model.ChannelList
|
||||
if rf, ok := ret.Get(0).(func(string, int, int) *model.ChannelList); ok {
|
||||
r0 = rf(teamId, offset, limit)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*model.ChannelList)
|
||||
}
|
||||
}
|
||||
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func(string, int, int) *model.AppError); ok {
|
||||
r1 = rf(teamId, offset, limit)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetPublicChannelsByIdsForTeam provides a mock function with given fields: teamId, channelIds
|
||||
func (_m *ChannelStore) GetPublicChannelsByIdsForTeam(teamId string, channelIds []string) (*model.ChannelList, *model.AppError) {
|
||||
ret := _m.Called(teamId, channelIds)
|
||||
|
||||
Ссылка в новой задаче
Block a user