MM-25261: Add 'include_deleted' parameter to get all channels API req… (#14721)

* MM-25261: Add 'include_deleted' parameter to get all channels API request.

* MM-25261: Adds test for deleted channels.

* MM-25261: Switches to single liner.

* MM-25261: Adhere to beta config setting for viewing archived channels.

* MM-25261: Test fix.

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Martin Kraft
2020-06-19 16:53:37 -04:00
коммит произвёл GitHub
родитель d391fd6231
Коммит 6158e91308
4 изменённых файлов: 49 добавлений и 1 удалений

Просмотреть файл

@@ -687,6 +687,7 @@ func getAllChannels(c *Context, w http.ResponseWriter, r *http.Request) {
opts := model.ChannelSearchOpts{
NotAssociatedToGroup: c.Params.NotAssociatedToGroup,
ExcludeDefaultChannels: c.Params.ExcludeDefaultChannels,
IncludeDeleted: c.Params.IncludeDeleted,
}
channels, err := c.App.GetAllChannels(c.Params.Page, c.Params.PerPage, opts)

Просмотреть файл

@@ -919,6 +919,15 @@ func TestGetAllChannels(t *testing.T) {
defer th.TearDown()
Client := th.Client
var originalConfigVal bool
th.App.UpdateConfig(func(cfg *model.Config) {
originalConfigVal = *cfg.TeamSettings.ExperimentalViewArchivedChannels
*cfg.TeamSettings.ExperimentalViewArchivedChannels = true
})
defer th.App.UpdateConfig(func(cfg *model.Config) {
*cfg.TeamSettings.ExperimentalViewArchivedChannels = originalConfigVal
})
th.TestForSystemAdminAndLocal(t, func(t *testing.T, client *model.Client4) {
channels, resp := client.GetAllChannels(0, 20, "")
CheckNoError(t, resp)
@@ -940,6 +949,34 @@ func TestGetAllChannels(t *testing.T) {
channels, resp = client.GetAllChannels(10000, 10000, "")
CheckNoError(t, resp)
require.Empty(t, *channels)
channels, resp = client.GetAllChannels(0, 10000, "")
require.Nil(t, resp.Error)
beforeCount := len(*channels)
firstChannel := (*channels)[0].Channel
ok, resp := client.DeleteChannel(firstChannel.Id)
require.Nil(t, resp.Error)
require.True(t, ok)
channels, resp = client.GetAllChannels(0, 10000, "")
var ids []string
for _, item := range *channels {
ids = append(ids, item.Channel.Id)
}
require.Nil(t, resp.Error)
require.Len(t, *channels, beforeCount-1)
require.NotContains(t, ids, firstChannel.Id)
channels, resp = client.GetAllChannelsIncludeDeleted(0, 10000, "")
ids = []string{}
for _, item := range *channels {
ids = append(ids, item.Channel.Id)
}
require.Nil(t, resp.Error)
require.True(t, len(*channels) > beforeCount)
require.Contains(t, ids, firstChannel.Id)
})
_, resp := Client.GetAllChannels(0, 20, "")