From 1f6c271b3bedd6656ae7155714423b1b39a669c1 Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Wed, 16 May 2018 13:43:22 -0400 Subject: MM-8708 Remove api package (#8784) * Remove api package * Remove api dependency from cmd package * Remove EnableAPIv3 setting * Update web tests * Add more websocket tests * Move some ws and oauth tests to api4 package * Move command tests into api4 package * Test fixes * Fix msg command test * Add some app file tests --- app/auto_users.go | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) (limited to 'app/auto_users.go') diff --git a/app/auto_users.go b/app/auto_users.go index b11f9c572..b61ab053f 100644 --- a/app/auto_users.go +++ b/app/auto_users.go @@ -12,7 +12,7 @@ import ( type AutoUserCreator struct { app *App - client *model.Client + client *model.Client4 team *model.Team EmailLength utils.Range EmailCharset string @@ -21,7 +21,7 @@ type AutoUserCreator struct { Fuzzy bool } -func NewAutoUserCreator(a *App, client *model.Client, team *model.Team) *AutoUserCreator { +func NewAutoUserCreator(a *App, client *model.Client4, team *model.Team) *AutoUserCreator { return &AutoUserCreator{ app: a, client: client, @@ -35,21 +35,19 @@ func NewAutoUserCreator(a *App, client *model.Client, team *model.Team) *AutoUse } // Basic test team and user so you always know one -func (a *App) CreateBasicUser(client *model.Client) *model.AppError { - result, _ := client.FindTeamByName(BTEST_TEAM_NAME) - if !result.Data.(bool) { +func (a *App) CreateBasicUser(client *model.Client4) *model.AppError { + found, _ := client.TeamExists(BTEST_TEAM_NAME, "") + if !found { newteam := &model.Team{DisplayName: BTEST_TEAM_DISPLAY_NAME, Name: BTEST_TEAM_NAME, Email: BTEST_TEAM_EMAIL, Type: BTEST_TEAM_TYPE} - result, err := client.CreateTeam(newteam) - if err != nil { - return err + basicteam, resp := client.CreateTeam(newteam) + if resp.Error != nil { + return resp.Error } - basicteam := result.Data.(*model.Team) newuser := &model.User{Email: BTEST_USER_EMAIL, Nickname: BTEST_USER_NAME, Password: BTEST_USER_PASSWORD} - result, err = client.CreateUser(newuser, "") - if err != nil { - return err + ruser, resp := client.CreateUser(newuser) + if resp.Error != nil { + return resp.Error } - ruser := result.Data.(*model.User) store.Must(a.Srv.Store.User().VerifyEmail(ruser.Id)) store.Must(a.Srv.Store.Team().SaveMember(&model.TeamMember{TeamId: basicteam.Id, UserId: ruser.Id}, *a.Config().TeamSettings.MaxUsersPerTeam)) } @@ -72,14 +70,12 @@ func (cfg *AutoUserCreator) createRandomUser() (*model.User, bool) { Nickname: userName, Password: USER_PASSWORD} - result, err := cfg.client.CreateUserWithInvite(user, "", "", cfg.team.InviteId) - if err != nil { - mlog.Error(err.Error()) + ruser, resp := cfg.client.CreateUserWithInviteId(user, cfg.team.InviteId) + if resp.Error != nil { + mlog.Error(resp.Error.Error()) return nil, false } - ruser := result.Data.(*model.User) - status := &model.Status{UserId: ruser.Id, Status: model.STATUS_ONLINE, Manual: false, LastActivityAt: model.GetMillis(), ActiveChannel: ""} if result := <-cfg.app.Srv.Store.Status().SaveOrUpdate(status); result.Err != nil { mlog.Error(result.Err.Error()) @@ -89,7 +85,7 @@ func (cfg *AutoUserCreator) createRandomUser() (*model.User, bool) { // We need to cheat to verify the user's email store.Must(cfg.app.Srv.Store.User().VerifyEmail(ruser.Id)) - return result.Data.(*model.User), true + return ruser, true } func (cfg *AutoUserCreator) CreateTestUsers(num utils.Range) ([]*model.User, bool) { -- cgit v1.2.3-1-g7c22