APIv4 get /channels/{channel_id}/pinned (#5893)

Этот коммит содержится в:
Saturnino Abril
2017-03-30 00:09:05 +09:00
коммит произвёл Corey Hulen
родитель 64f80decaf
Коммит 8a31718db1
5 изменённых файлов: 102 добавлений и 0 удалений

Просмотреть файл

@@ -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()