diff options
author | Joram Wilander <jwawilander@gmail.com> | 2017-02-13 10:52:50 -0500 |
---|---|---|
committer | Corey Hulen <corey@hulen.com> | 2017-02-13 10:52:50 -0500 |
commit | e4effd0c15a188eeec7a11f281e529afd6a54f80 (patch) | |
tree | 2c9b0f451366c54e163ac6f4743adf9e1cbd9a26 /api4/apitestlib.go | |
parent | 260f1111e8988b177550d2621fbf99df178ca57a (diff) | |
download | chat-e4effd0c15a188eeec7a11f281e529afd6a54f80.tar.gz chat-e4effd0c15a188eeec7a11f281e529afd6a54f80.tar.bz2 chat-e4effd0c15a188eeec7a11f281e529afd6a54f80.zip |
Implement some post endpoints for APIv4 (#5353)
* Implement POST /posts endpoint for APIv4
* Implement GET /channels/{channel_id}/posts endpoint for APIv4
* Implement GET /posts/{post_id} endpoint for APIv4
* Implement GET /posts/{post_id}/thread endpoint for APIv4
* Skip team get if it's a DM channel in handlePostEvents
Diffstat (limited to 'api4/apitestlib.go')
-rw-r--r-- | api4/apitestlib.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/api4/apitestlib.go b/api4/apitestlib.go index 25bfe6f75..0761a8b15 100644 --- a/api4/apitestlib.go +++ b/api4/apitestlib.go @@ -26,6 +26,8 @@ type TestHelper struct { TeamAdminUser *model.User BasicTeam *model.Team BasicChannel *model.Channel + BasicChannel2 *model.Channel + BasicPost *model.Post SystemAdminClient *model.Client4 SystemAdminUser *model.User @@ -97,12 +99,16 @@ func (me *TestHelper) InitBasic() *TestHelper { me.LoginTeamAdmin() me.BasicTeam = me.CreateTeam() me.BasicChannel = me.CreatePublicChannel() + me.BasicChannel2 = me.CreatePublicChannel() + me.BasicPost = me.CreatePost() me.BasicUser = me.CreateUser() LinkUserToTeam(me.BasicUser, me.BasicTeam) me.BasicUser2 = me.CreateUser() LinkUserToTeam(me.BasicUser2, me.BasicTeam) app.AddUserToChannel(me.BasicUser, me.BasicChannel) app.AddUserToChannel(me.BasicUser2, me.BasicChannel) + app.AddUserToChannel(me.BasicUser, me.BasicChannel2) + app.AddUserToChannel(me.BasicUser2, me.BasicChannel2) app.UpdateUserRoles(me.BasicUser.Id, model.ROLE_SYSTEM_USER.Id) me.LoginBasic() @@ -188,6 +194,27 @@ func (me *TestHelper) CreateChannelWithClient(client *model.Client4, channelType return rchannel } +func (me *TestHelper) CreatePost() *model.Post { + return me.CreatePostWithClient(me.Client, me.BasicChannel) +} + +func (me *TestHelper) CreatePostWithClient(client *model.Client4, channel *model.Channel) *model.Post { + id := model.NewId() + + post := &model.Post{ + ChannelId: channel.Id, + Message: "message_" + id, + } + + utils.DisableDebugLogForTest() + rpost, resp := client.CreatePost(post) + if resp.Error != nil { + panic(resp.Error) + } + utils.EnableDebugLogForTest() + return rpost +} + func (me *TestHelper) LoginBasic() { me.LoginBasicWithClient(me.Client) } |