diff options
author | Carlos Tadeu Panato Junior <ctadeu@gmail.com> | 2016-12-30 17:44:05 +0100 |
---|---|---|
committer | enahum <nahumhbl@gmail.com> | 2016-12-30 13:44:04 -0300 |
commit | 21af988e4973a7c51a6b48814bb0366454410c72 (patch) | |
tree | b3ec979fd2a2aa4bb2c9b50e5f3e8b37486910d0 /model | |
parent | 42da7aa700cb34b77134d36b5ae9e530f80502cc (diff) | |
download | chat-21af988e4973a7c51a6b48814bb0366454410c72.tar.gz chat-21af988e4973a7c51a6b48814bb0366454410c72.tar.bz2 chat-21af988e4973a7c51a6b48814bb0366454410c72.zip |
Add initial unit test for post.getPostById() (#4910)
* add itinial tests for GetPostById
update per review
fix lint
* add missing comment
Diffstat (limited to 'model')
-rw-r--r-- | model/client.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/model/client.go b/model/client.go index 54095fcba..7248ca951 100644 --- a/model/client.go +++ b/model/client.go @@ -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 |