2015-10-08 12:27:09 -04:00
|
|
|
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
|
2015-06-14 23:53:32 -08:00
|
|
|
// See License.txt for license information.
|
|
|
|
|
|
|
|
|
|
package api
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"github.com/mattermost/platform/model"
|
2015-07-06 00:50:42 -08:00
|
|
|
"github.com/mattermost/platform/store"
|
2015-06-14 23:53:32 -08:00
|
|
|
"github.com/mattermost/platform/utils"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var Client *model.Client
|
|
|
|
|
|
|
|
|
|
func Setup() {
|
|
|
|
|
if Srv == nil {
|
|
|
|
|
utils.LoadConfig("config.json")
|
2016-01-20 14:36:34 -06:00
|
|
|
utils.InitTranslations()
|
2015-09-22 01:15:41 -07:00
|
|
|
utils.Cfg.TeamSettings.MaxUsersPerTeam = 50
|
2015-06-14 23:53:32 -08:00
|
|
|
NewServer()
|
|
|
|
|
StartServer()
|
|
|
|
|
InitApi()
|
2015-09-22 12:12:50 -07:00
|
|
|
Client = model.NewClient("http://localhost" + utils.Cfg.ServiceSettings.ListenAddress)
|
2015-10-15 11:16:26 -07:00
|
|
|
|
|
|
|
|
Srv.Store.MarkSystemRanUnitTests()
|
2015-06-14 23:53:32 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func SetupBenchmark() (*model.Team, *model.User, *model.Channel) {
|
|
|
|
|
Setup()
|
|
|
|
|
|
2015-07-08 11:50:10 -04:00
|
|
|
team := &model.Team{DisplayName: "Benchmark Team", Name: "z-z-" + model.NewId() + "a", Email: "benchmark@nowhere.com", Type: model.TEAM_OPEN}
|
2015-06-14 23:53:32 -08:00
|
|
|
team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team)
|
2015-07-09 13:59:19 -04:00
|
|
|
user := &model.User{TeamId: team.Id, Email: model.NewId() + "benchmark@test.com", Nickname: "Mr. Benchmarker", Password: "pwd"}
|
2015-06-14 23:53:32 -08:00
|
|
|
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
2016-01-20 13:36:16 -06:00
|
|
|
store.Must(Srv.Store.User().VerifyEmail(user.Id))
|
2015-07-08 11:50:10 -04:00
|
|
|
Client.LoginByEmail(team.Name, user.Email, "pwd")
|
2015-06-14 23:53:32 -08:00
|
|
|
channel := &model.Channel{DisplayName: "Benchmark Channel", Name: "a" + model.NewId() + "a", Type: model.CHANNEL_OPEN, TeamId: team.Id}
|
|
|
|
|
channel = Client.Must(Client.CreateChannel(channel)).Data.(*model.Channel)
|
|
|
|
|
|
|
|
|
|
return team, user, channel
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TearDown() {
|
|
|
|
|
if Srv != nil {
|
|
|
|
|
StopServer()
|
|
|
|
|
}
|
|
|
|
|
}
|