summaryrefslogtreecommitdiffstats
path: root/api/channel_test.go
diff options
context:
space:
mode:
authorGabin Aureche <gabin.aureche@live.fr>2017-03-13 13:25:08 +0100
committerGeorge Goldberg <george@gberg.me>2017-03-13 12:25:08 +0000
commitfe38d6d5bb36e18ddefbe490cc21f48f4f4c8d81 (patch)
treeb96d457cde64b7397f91028106e93a7f92a179bd /api/channel_test.go
parent482a0fb5fc248b1ec61db35299dc3e6d963ad5ab (diff)
downloadchat-fe38d6d5bb36e18ddefbe490cc21f48f4f4c8d81.tar.gz
chat-fe38d6d5bb36e18ddefbe490cc21f48f4f4c8d81.tar.bz2
chat-fe38d6d5bb36e18ddefbe490cc21f48f4f4c8d81.zip
Add pinned posts (#4217)
Diffstat (limited to 'api/channel_test.go')
-rw-r--r--api/channel_test.go33
1 files changed, 27 insertions, 6 deletions
diff --git a/api/channel_test.go b/api/channel_test.go
index 93c79d416..08136bc35 100644
--- a/api/channel_test.go
+++ b/api/channel_test.go
@@ -926,8 +926,8 @@ func TestGetMoreChannelsPage(t *testing.T) {
} else {
channels := r.Data.(*model.ChannelList)
- // 1 for BasicChannel, 2 for open channels created above
- if len(*channels) != 3 {
+ // 1 for BasicChannel, 1 for PinnedPostChannel, 2 for open channels created above
+ if len(*channels) != 4 {
t.Fatal("wrong length")
}
@@ -990,11 +990,11 @@ func TestGetChannelCounts(t *testing.T) {
} else {
counts := result.Data.(*model.ChannelCounts)
- if len(counts.Counts) != 5 {
+ if len(counts.Counts) != 6 {
t.Fatal("wrong number of channel counts")
}
- if len(counts.UpdateTimes) != 5 {
+ if len(counts.UpdateTimes) != 6 {
t.Fatal("wrong number of channel update times")
}
@@ -1024,8 +1024,8 @@ func TestGetMyChannelMembers(t *testing.T) {
} else {
members := result.Data.(*model.ChannelMembers)
- // town-square, off-topic, basic test channel, channel1, channel2
- if len(*members) != 5 {
+ // town-square, off-topic, basic test channel, pinned post channel, channel1, channel2
+ if len(*members) != 6 {
t.Fatal("wrong number of members", len(*members))
}
}
@@ -2117,3 +2117,24 @@ func TestUpdateChannelRoles(t *testing.T) {
t.Fatal("Channel member should not be able to promote itself to channel admin:", meta)
}
}
+
+func TestGetPinnedPosts(t *testing.T) {
+ th := Setup().InitBasic()
+ Client := th.BasicClient
+
+ post1 := th.BasicPost
+ r1 := Client.Must(Client.GetPinnedPosts(post1.ChannelId)).Data.(*model.PostList)
+ if len(r1.Order) != 0 {
+ t.Fatal("should not have gotten a pinned post")
+ }
+
+ post2 := th.PinnedPost
+ r2 := Client.Must(Client.GetPinnedPosts(post2.ChannelId)).Data.(*model.PostList)
+ if len(r2.Order) == 0 {
+ t.Fatal("should have gotten a pinned post")
+ }
+
+ if _, ok := r2.Posts[post2.Id]; !ok {
+ t.Fatal("missing pinned post")
+ }
+}