diff options
author | Saturnino Abril <saturnino.abril@gmail.com> | 2017-03-27 20:41:40 +0900 |
---|---|---|
committer | enahum <nahumhbl@gmail.com> | 2017-03-27 08:41:40 -0300 |
commit | 01aaccb34080ede234602d1ca9acee8373b8560f (patch) | |
tree | aac605bdc35f8a2f1a2761c7f753d5e9f66a33ec /store/sql_channel_store_test.go | |
parent | 720ee81113ac7a7dd062271c3d6cdf58ce8e044a (diff) | |
download | chat-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 'store/sql_channel_store_test.go')
-rw-r--r-- | store/sql_channel_store_test.go | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/store/sql_channel_store_test.go b/store/sql_channel_store_test.go index f347fa438..3cc6f3bc4 100644 --- a/store/sql_channel_store_test.go +++ b/store/sql_channel_store_test.go @@ -934,6 +934,87 @@ func TestChannelStoreGetPublicChannelsForTeam(t *testing.T) { } } +func TestChannelStoreGetPublicChannelsByIdsForTeam(t *testing.T) { + Setup() + + teamId1 := model.NewId() + + oc1 := model.Channel{} + oc1.TeamId = teamId1 + oc1.DisplayName = "OpenChannel1Team1" + oc1.Name = "a" + model.NewId() + "b" + oc1.Type = model.CHANNEL_OPEN + Must(store.Channel().Save(&oc1)) + + oc2 := model.Channel{} + oc2.TeamId = model.NewId() + oc2.DisplayName = "OpenChannel2TeamOther" + oc2.Name = "a" + model.NewId() + "b" + oc2.Type = model.CHANNEL_OPEN + Must(store.Channel().Save(&oc2)) + + pc3 := model.Channel{} + pc3.TeamId = teamId1 + pc3.DisplayName = "PrivateChannel3Team1" + pc3.Name = "a" + model.NewId() + "b" + pc3.Type = model.CHANNEL_PRIVATE + Must(store.Channel().Save(&pc3)) + + cids := []string{oc1.Id} + cresult := <-store.Channel().GetPublicChannelsByIdsForTeam(teamId1, cids) + list := cresult.Data.(*model.ChannelList) + + if len(*list) != 1 { + t.Fatal("should return 1 channel") + } + + if (*list)[0].Id != oc1.Id { + t.Fatal("missing channel") + } + + cids = append(cids, oc2.Id) + cids = append(cids, model.NewId()) + cids = append(cids, pc3.Id) + cresult = <-store.Channel().GetPublicChannelsByIdsForTeam(teamId1, cids) + list = cresult.Data.(*model.ChannelList) + + if len(*list) != 1 { + t.Fatal("should return 1 channel") + } + + oc4 := model.Channel{} + oc4.TeamId = teamId1 + oc4.DisplayName = "OpenChannel4Team1" + oc4.Name = "a" + model.NewId() + "b" + oc4.Type = model.CHANNEL_OPEN + Must(store.Channel().Save(&oc4)) + + cids = append(cids, oc4.Id) + cresult = <-store.Channel().GetPublicChannelsByIdsForTeam(teamId1, cids) + list = cresult.Data.(*model.ChannelList) + + if len(*list) != 2 { + t.Fatal("should return 2 channels") + } + + if (*list)[0].Id != oc1.Id { + t.Fatal("missing channel") + } + + if (*list)[1].Id != oc4.Id { + t.Fatal("missing channel") + } + + cids = cids[:0] + cids = append(cids, model.NewId()) + cresult = <-store.Channel().GetPublicChannelsByIdsForTeam(teamId1, cids) + list = cresult.Data.(*model.ChannelList) + + if len(*list) != 0 { + t.Fatal("should not return a channel") + } +} + func TestChannelStoreGetChannelCounts(t *testing.T) { Setup() |