Add initial unit test for post.getPostById() (#4910)

* add itinial tests for GetPostById

update per review

fix lint

* add missing comment
Этот коммит содержится в:
Carlos Tadeu Panato Junior
2016-12-30 17:44:05 +01:00
коммит произвёл enahum
родитель 42da7aa700
Коммит 21af988e49
2 изменённых файлов: 45 добавлений и 0 удалений

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

@@ -1483,6 +1483,21 @@ func (c *Client) GetPost(channelId string, postId string, etag string) (*Result,
}
}
// GetPostById returns a post and any posts in the same thread by post id
func (c *Client) GetPostById(postId string, etag string) (*PostList, *ResponseMetadata) {
if r, err := c.DoApiGet(c.GetTeamRoute()+fmt.Sprintf("/posts/%v", postId), "", etag); err != nil {
return nil, &ResponseMetadata{StatusCode: r.StatusCode, Error: err}
} else {
defer closeBody(r)
return PostListFromJson(r.Body),
&ResponseMetadata{
StatusCode: r.StatusCode,
RequestId: r.Header.Get(HEADER_REQUEST_ID),
Etag: r.Header.Get(HEADER_ETAG_SERVER),
}
}
}
func (c *Client) DeletePost(channelId string, postId string) (*Result, *AppError) {
if r, err := c.DoApiPost(c.GetChannelRoute(channelId)+fmt.Sprintf("/posts/%v/delete", postId), ""); err != nil {
return nil, err