summaryrefslogtreecommitdiffstats
path: root/api4/channel_test.go
diff options
context:
space:
mode:
authorSaturnino Abril <saturnino.abril@gmail.com>2017-03-30 00:09:05 +0900
committerCorey Hulen <corey@hulen.com>2017-03-29 08:09:05 -0700
commit8a31718db11c803fa3b14f85c760ca9db6083670 (patch)
tree80a006c8994ef57ccd6d09fc7b0d00ebe6969f39 /api4/channel_test.go
parent64f80decaf4c20c643e43426e3c4285b2d501a90 (diff)
downloadchat-8a31718db11c803fa3b14f85c760ca9db6083670.tar.gz
chat-8a31718db11c803fa3b14f85c760ca9db6083670.tar.bz2
chat-8a31718db11c803fa3b14f85c760ca9db6083670.zip
APIv4 get /channels/{channel_id}/pinned (#5893)
Diffstat (limited to 'api4/channel_test.go')
-rw-r--r--api4/channel_test.go39
1 files changed, 39 insertions, 0 deletions
diff --git a/api4/channel_test.go b/api4/channel_test.go
index 3d501b313..3cc1cb64f 100644
--- a/api4/channel_test.go
+++ b/api4/channel_test.go
@@ -1322,6 +1322,45 @@ func TestGetChannelStats(t *testing.T) {
CheckNoError(t, resp)
}
+func TestGetPinnedPosts(t *testing.T) {
+ th := Setup().InitBasic().InitSystemAdmin()
+ defer TearDown()
+ Client := th.Client
+ channel := th.BasicChannel
+
+ posts, resp := Client.GetPinnedPosts(channel.Id, "")
+ CheckNoError(t, resp)
+ if len(posts.Posts) != 0 {
+ t.Fatal("should not have gotten a pinned post")
+ }
+
+ pinnedPost := th.CreatePinnedPost()
+ posts, resp = Client.GetPinnedPosts(channel.Id, "")
+ CheckNoError(t, resp)
+ if len(posts.Posts) != 1 {
+ t.Fatal("should have returned 1 pinned post")
+ }
+ if _, ok := posts.Posts[pinnedPost.Id]; !ok {
+ t.Fatal("missing pinned post")
+ }
+
+ posts, resp = Client.GetPinnedPosts(channel.Id, resp.Etag)
+ CheckEtag(t, posts, resp)
+
+ _, resp = Client.GetPinnedPosts(GenerateTestId(), "")
+ CheckForbiddenStatus(t, resp)
+
+ _, resp = Client.GetPinnedPosts("junk", "")
+ CheckBadRequestStatus(t, resp)
+
+ Client.Logout()
+ _, resp = Client.GetPinnedPosts(channel.Id, "")
+ CheckUnauthorizedStatus(t, resp)
+
+ _, resp = th.SystemAdminClient.GetPinnedPosts(channel.Id, "")
+ CheckNoError(t, resp)
+}
+
func TestUpdateChannelRoles(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
defer TearDown()