summaryrefslogtreecommitdiffstats
path: root/api/channel_test.go
diff options
context:
space:
mode:
author=Corey Hulen <corey@hulen.com>2016-01-14 09:08:13 -0600
committer=Corey Hulen <corey@hulen.com>2016-01-14 09:08:13 -0600
commit6d6cada0970a2b341f36dac9b0fed8262ada1865 (patch)
treefc3728f15deaebd0c870838a63735659a33456e7 /api/channel_test.go
parent0b986ed3147c885af6b2f33e1ff3eb6754e8f274 (diff)
parenta341dbad2b8a4564b6f270c79f2f9932e499ac80 (diff)
downloadchat-6d6cada0970a2b341f36dac9b0fed8262ada1865.tar.gz
chat-6d6cada0970a2b341f36dac9b0fed8262ada1865.tar.bz2
chat-6d6cada0970a2b341f36dac9b0fed8262ada1865.zip
Merge branch 'master' into PLT-1429
Diffstat (limited to 'api/channel_test.go')
-rw-r--r--api/channel_test.go48
1 files changed, 42 insertions, 6 deletions
diff --git a/api/channel_test.go b/api/channel_test.go
index 4ef164cba..117278378 100644
--- a/api/channel_test.go
+++ b/api/channel_test.go
@@ -674,7 +674,7 @@ func TestGetChannelExtraInfo(t *testing.T) {
channel1 := &model.Channel{DisplayName: "A Test API Name", Name: "a" + model.NewId() + "a", Type: model.CHANNEL_OPEN, TeamId: team.Id}
channel1 = Client.Must(Client.CreateChannel(channel1)).Data.(*model.Channel)
- rget := Client.Must(Client.GetChannelExtraInfo(channel1.Id, ""))
+ rget := Client.Must(Client.GetChannelExtraInfo(channel1.Id, -1, ""))
data := rget.Data.(*model.ChannelExtra)
if data.Id != channel1.Id {
t.Fatal("couldnt't get extra info")
@@ -690,7 +690,7 @@ func TestGetChannelExtraInfo(t *testing.T) {
currentEtag := rget.Etag
- if cache_result, err := Client.GetChannelExtraInfo(channel1.Id, currentEtag); err != nil {
+ if cache_result, err := Client.GetChannelExtraInfo(channel1.Id, -1, currentEtag); err != nil {
t.Fatal(err)
} else if cache_result.Data.(*model.ChannelExtra) != nil {
t.Log(cache_result.Data)
@@ -708,7 +708,7 @@ func TestGetChannelExtraInfo(t *testing.T) {
Client2.LoginByEmail(team.Name, user2.Email, "pwd")
Client2.Must(Client2.JoinChannel(channel1.Id))
- if cache_result, err := Client.GetChannelExtraInfo(channel1.Id, currentEtag); err != nil {
+ if cache_result, err := Client.GetChannelExtraInfo(channel1.Id, -1, currentEtag); err != nil {
t.Fatal(err)
} else if cache_result.Data.(*model.ChannelExtra) == nil {
t.Log(cache_result.Data)
@@ -717,7 +717,7 @@ func TestGetChannelExtraInfo(t *testing.T) {
currentEtag = cache_result.Etag
}
- if cache_result, err := Client.GetChannelExtraInfo(channel1.Id, currentEtag); err != nil {
+ if cache_result, err := Client.GetChannelExtraInfo(channel1.Id, -1, currentEtag); err != nil {
t.Fatal(err)
} else if cache_result.Data.(*model.ChannelExtra) != nil {
t.Log(cache_result.Data)
@@ -728,7 +728,7 @@ func TestGetChannelExtraInfo(t *testing.T) {
Client2.Must(Client2.LeaveChannel(channel1.Id))
- if cache_result, err := Client.GetChannelExtraInfo(channel1.Id, currentEtag); err != nil {
+ if cache_result, err := Client.GetChannelExtraInfo(channel1.Id, -1, currentEtag); err != nil {
t.Fatal(err)
} else if cache_result.Data.(*model.ChannelExtra) == nil {
t.Log(cache_result.Data)
@@ -737,7 +737,7 @@ func TestGetChannelExtraInfo(t *testing.T) {
currentEtag = cache_result.Etag
}
- if cache_result, err := Client.GetChannelExtraInfo(channel1.Id, currentEtag); err != nil {
+ if cache_result, err := Client.GetChannelExtraInfo(channel1.Id, -1, currentEtag); err != nil {
t.Fatal(err)
} else if cache_result.Data.(*model.ChannelExtra) != nil {
t.Log(cache_result.Data)
@@ -745,6 +745,42 @@ func TestGetChannelExtraInfo(t *testing.T) {
} else {
currentEtag = cache_result.Etag
}
+
+ Client2.Must(Client2.JoinChannel(channel1.Id))
+
+ if cache_result, err := Client.GetChannelExtraInfo(channel1.Id, 2, currentEtag); err != nil {
+ t.Fatal(err)
+ } else if extra := cache_result.Data.(*model.ChannelExtra); extra == nil {
+ t.Fatal("response should not be empty")
+ } else if len(extra.Members) != 2 {
+ t.Fatal("should've returned 2 members")
+ } else if extra.MemberCount != 2 {
+ t.Fatal("should've returned member count of 2")
+ } else {
+ currentEtag = cache_result.Etag
+ }
+
+ if cache_result, err := Client.GetChannelExtraInfo(channel1.Id, 1, currentEtag); err != nil {
+ t.Fatal(err)
+ } else if extra := cache_result.Data.(*model.ChannelExtra); extra == nil {
+ t.Fatal("response should not be empty")
+ } else if len(extra.Members) != 1 {
+ t.Fatal("should've returned only 1 member")
+ } else if extra.MemberCount != 2 {
+ t.Fatal("should've returned member count of 2")
+ } else {
+ currentEtag = cache_result.Etag
+ }
+
+ if cache_result, err := Client.GetChannelExtraInfo(channel1.Id, 1, currentEtag); err != nil {
+ t.Fatal(err)
+ } else if cache_result.Data.(*model.ChannelExtra) != nil {
+ t.Log(cache_result.Data)
+ t.Fatal("response should be empty")
+ } else {
+ currentEtag = cache_result.Etag
+ }
+
}
func TestAddChannelMember(t *testing.T) {