diff options
Diffstat (limited to 'api4/apitestlib.go')
-rw-r--r-- | api4/apitestlib.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/api4/apitestlib.go b/api4/apitestlib.go index 6b129dd8f..d5706bf2b 100644 --- a/api4/apitestlib.go +++ b/api4/apitestlib.go @@ -25,6 +25,7 @@ type TestHelper struct { BasicUser2 *model.User TeamAdminUser *model.User BasicTeam *model.Team + BasicChannel *model.Channel SystemAdminClient *model.Client4 SystemAdminUser *model.User @@ -63,6 +64,7 @@ func (me *TestHelper) InitBasic() *TestHelper { me.TeamAdminUser = me.CreateUser() me.LoginTeamAdmin() me.BasicTeam = me.CreateTeam() + me.BasicChannel = me.CreatePublicChannel() me.BasicUser = me.CreateUser() LinkUserToTeam(me.BasicUser, me.BasicTeam) me.BasicUser2 = me.CreateUser() @@ -128,6 +130,30 @@ func (me *TestHelper) CreateUserWithClient(client *model.Client4) *model.User { return ruser } +func (me *TestHelper) CreatePublicChannel() *model.Channel { + return me.CreateChannelWithClient(me.Client, model.CHANNEL_OPEN) +} + +func (me *TestHelper) CreatePrivateChannel() *model.Channel { + return me.CreateChannelWithClient(me.Client, model.CHANNEL_PRIVATE) +} + +func (me *TestHelper) CreateChannelWithClient(client *model.Client4, channelType string) *model.Channel { + id := model.NewId() + + channel := &model.Channel{ + DisplayName: "dn_" + id, + Name: GenerateTestChannelName(), + Type: channelType, + TeamId: me.BasicTeam.Id, + } + + utils.DisableDebugLogForTest() + rchannel, _ := client.CreateChannel(channel) + utils.EnableDebugLogForTest() + return rchannel +} + func (me *TestHelper) LoginBasic() { me.LoginBasicWithClient(me.Client) } @@ -194,6 +220,10 @@ func GenerateTestTeamName() string { return "faketeam" + model.NewId() } +func GenerateTestChannelName() string { + return "fakechannel" + model.NewId() +} + func VerifyUserEmail(userId string) { store.Must(app.Srv.Store.User().VerifyEmail(userId)) } |