summaryrefslogtreecommitdiffstats
path: root/store/sql_channel_store_test.go
diff options
context:
space:
mode:
authorGeorge Goldberg <george@gberg.me>2016-12-22 18:21:05 +0000
committerCorey Hulen <corey@hulen.com>2016-12-22 10:21:05 -0800
commit53847af2c4e84e6dc81b12fb6481cb8dfbf701b9 (patch)
tree25ab583993593e17b06c20429d46714ff6a50b95 /store/sql_channel_store_test.go
parentb79b2b2a53935cd883312c1158918291a926bacd (diff)
downloadchat-53847af2c4e84e6dc81b12fb6481cb8dfbf701b9.tar.gz
chat-53847af2c4e84e6dc81b12fb6481cb8dfbf701b9.tar.bz2
chat-53847af2c4e84e6dc81b12fb6481cb8dfbf701b9.zip
API for getting channel members by IDs. (#4877)
Diffstat (limited to 'store/sql_channel_store_test.go')
-rw-r--r--store/sql_channel_store_test.go45
1 files changed, 45 insertions, 0 deletions
diff --git a/store/sql_channel_store_test.go b/store/sql_channel_store_test.go
index d4bcf6b26..b2a644c15 100644
--- a/store/sql_channel_store_test.go
+++ b/store/sql_channel_store_test.go
@@ -1280,3 +1280,48 @@ func TestChannelStoreSearchInTeam(t *testing.T) {
}
}
}
+
+func TestChannelStoreGetMembersByIds(t *testing.T) {
+ Setup()
+
+ o1 := model.Channel{}
+ o1.TeamId = model.NewId()
+ o1.DisplayName = "ChannelA"
+ o1.Name = "a" + model.NewId() + "b"
+ o1.Type = model.CHANNEL_OPEN
+ Must(store.Channel().Save(&o1))
+
+ m1 := &model.ChannelMember{ChannelId: o1.Id, UserId: model.NewId(), NotifyProps: model.GetDefaultChannelNotifyProps()}
+ Must(store.Channel().SaveMember(m1))
+
+ if r := <-store.Channel().GetMembersByIds(m1.ChannelId, []string{m1.UserId}); r.Err != nil {
+ t.Fatal(r.Err)
+ } else {
+ rm1 := r.Data.(model.ChannelMembers)[0]
+
+ if rm1.ChannelId != m1.ChannelId {
+ t.Fatal("bad team id")
+ }
+
+ if rm1.UserId != m1.UserId {
+ t.Fatal("bad user id")
+ }
+ }
+
+ m2 := &model.ChannelMember{ChannelId: o1.Id, UserId: model.NewId(), NotifyProps: model.GetDefaultChannelNotifyProps()}
+ Must(store.Channel().SaveMember(m2))
+
+ if r := <-store.Channel().GetMembersByIds(m1.ChannelId, []string{m1.UserId, m2.UserId, model.NewId()}); r.Err != nil {
+ t.Fatal(r.Err)
+ } else {
+ rm := r.Data.(model.ChannelMembers)
+
+ if len(rm) != 2 {
+ t.Fatal("return wrong number of results")
+ }
+ }
+
+ if r := <-store.Channel().GetMembersByIds(m1.ChannelId, []string{}); r.Err == nil {
+ t.Fatal("empty user ids - should have failed")
+ }
+}