diff options
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) } |