summaryrefslogtreecommitdiffstats
path: root/api4/channel_test.go
diff options
context:
space:
mode:
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()