summaryrefslogtreecommitdiffstats
path: root/api4/channel_test.go
diff options
context:
space:
mode:
authorSaturnino Abril <saturnino.abril@gmail.com>2017-03-27 20:41:40 +0900
committerenahum <nahumhbl@gmail.com>2017-03-27 08:41:40 -0300
commit01aaccb34080ede234602d1ca9acee8373b8560f (patch)
treeaac605bdc35f8a2f1a2761c7f753d5e9f66a33ec /api4/channel_test.go
parent720ee81113ac7a7dd062271c3d6cdf58ce8e044a (diff)
downloadchat-01aaccb34080ede234602d1ca9acee8373b8560f.tar.gz
chat-01aaccb34080ede234602d1ca9acee8373b8560f.tar.bz2
chat-01aaccb34080ede234602d1ca9acee8373b8560f.zip
APIv4 post /channels/ids (#5845)
* APIv4 post /channels/ids * updated enpoint as /teams/{team_id}/channels/ids
Diffstat (limited to 'api4/channel_test.go')
-rw-r--r--api4/channel_test.go63
1 files changed, 63 insertions, 0 deletions
diff --git a/api4/channel_test.go b/api4/channel_test.go
index a208313df..3d501b313 100644
--- a/api4/channel_test.go
+++ b/api4/channel_test.go
@@ -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()