* APIv4 post /channels/ids

* updated enpoint as /teams/{team_id}/channels/ids
Этот коммит содержится в:
Saturnino Abril
2017-03-27 20:41:40 +09:00
коммит произвёл enahum
родитель 720ee81113
Коммит 01aaccb340
8 изменённых файлов: 259 добавлений и 5 удалений

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

@@ -6,6 +6,7 @@ package api4
import (
"fmt"
"net/http"
"sort"
"strconv"
"testing"
@@ -494,6 +495,68 @@ func TestGetPublicChannelsForTeam(t *testing.T) {
CheckNoError(t, resp)
}
func TestGetPublicChannelsByIdsForTeam(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
defer TearDown()
Client := th.Client
teamId := th.BasicTeam.Id
input := []string{th.BasicChannel.Id}
output := []string{th.BasicChannel.DisplayName}
channels, resp := Client.GetPublicChannelsByIdsForTeam(teamId, input)
CheckNoError(t, resp)
if len(*channels) != 1 {
t.Fatal("should return 1 channel")
}
if (*channels)[0].DisplayName != output[0] {
t.Fatal("missing channel")
}
input = append(input, GenerateTestId())
input = append(input, th.BasicChannel2.Id)
input = append(input, th.BasicPrivateChannel.Id)
output = append(output, th.BasicChannel2.DisplayName)
sort.Strings(output)
channels, resp = Client.GetPublicChannelsByIdsForTeam(teamId, input)
CheckNoError(t, resp)
if len(*channels) != 2 {
t.Fatal("should return 2 channels")
}
for i, c := range *channels {
if c.DisplayName != output[i] {
t.Fatal("missing channel")
}
}
_, resp = Client.GetPublicChannelsByIdsForTeam(GenerateTestId(), input)
CheckForbiddenStatus(t, resp)
_, resp = Client.GetPublicChannelsByIdsForTeam(teamId, []string{})
CheckBadRequestStatus(t, resp)
_, resp = Client.GetPublicChannelsByIdsForTeam(teamId, []string{"junk"})
CheckBadRequestStatus(t, resp)
_, resp = Client.GetPublicChannelsByIdsForTeam(teamId, []string{GenerateTestId()})
CheckNotFoundStatus(t, resp)
_, resp = Client.GetPublicChannelsByIdsForTeam(teamId, []string{th.BasicPrivateChannel.Id})
CheckNotFoundStatus(t, resp)
Client.Logout()
_, resp = Client.GetPublicChannelsByIdsForTeam(teamId, input)
CheckUnauthorizedStatus(t, resp)
_, resp = th.SystemAdminClient.GetPublicChannelsByIdsForTeam(teamId, input)
CheckNoError(t, resp)
}
func TestGetChannelsForTeamForUser(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
defer TearDown()