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
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
02f8c18f40
Коммит
1f6c271b3b
@@ -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) {
|
||||
|
||||
Ссылка в новой задаче
Block a user