diff options
author | George Goldberg <george@gberg.me> | 2016-12-22 18:21:05 +0000 |
---|---|---|
committer | Corey Hulen <corey@hulen.com> | 2016-12-22 10:21:05 -0800 |
commit | 53847af2c4e84e6dc81b12fb6481cb8dfbf701b9 (patch) | |
tree | 25ab583993593e17b06c20429d46714ff6a50b95 /api/channel_test.go | |
parent | b79b2b2a53935cd883312c1158918291a926bacd (diff) | |
download | chat-53847af2c4e84e6dc81b12fb6481cb8dfbf701b9.tar.gz chat-53847af2c4e84e6dc81b12fb6481cb8dfbf701b9.tar.bz2 chat-53847af2c4e84e6dc81b12fb6481cb8dfbf701b9.zip |
API for getting channel members by IDs. (#4877)
Diffstat (limited to 'api/channel_test.go')
-rw-r--r-- | api/channel_test.go | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/api/channel_test.go b/api/channel_test.go index d24a6d603..d1bd66a02 100644 --- a/api/channel_test.go +++ b/api/channel_test.go @@ -1777,3 +1777,40 @@ func TestViewChannel(t *testing.T) { t.Fatal("message counts don't match") } } + +func TestGetChannelMembersByIds(t *testing.T) { + th := Setup().InitBasic() + + if _, err := AddUserToChannel(th.BasicUser2, th.BasicChannel); err != nil { + t.Fatal("Could not add second user to channel") + } + + if result, err := th.BasicClient.GetChannelMembersByIds(th.BasicChannel.Id, []string{th.BasicUser.Id}); err != nil { + t.Fatal(err) + } else { + member := (*result.Data.(*model.ChannelMembers))[0] + if member.UserId != th.BasicUser.Id { + t.Fatal("user id did not match") + } + if member.ChannelId != th.BasicChannel.Id { + t.Fatal("team id did not match") + } + } + + if result, err := th.BasicClient.GetChannelMembersByIds(th.BasicChannel.Id, []string{th.BasicUser.Id, th.BasicUser2.Id, model.NewId()}); err != nil { + t.Fatal(err) + } else { + members := result.Data.(*model.ChannelMembers) + if len(*members) != 2 { + t.Fatal("length should have been 2, got ", len(*members)) + } + } + + if _, err := th.BasicClient.GetChannelMembersByIds("junk", []string{th.BasicUser.Id}); err == nil { + t.Fatal("should have errored - bad team id") + } + + if _, err := th.BasicClient.GetChannelMembersByIds(th.BasicChannel.Id, []string{}); err == nil { + t.Fatal("should have errored - empty user ids") + } +} |