Finally remove utils.Cfg (#8113)
* finally remove utils.Cfg * fix compile error * another test compilation fix
Этот коммит содержится в:
коммит произвёл
Harrison Healey
родитель
dce0616305
Коммит
4e6cc846a6
@@ -7,6 +7,7 @@ import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
@@ -33,7 +34,7 @@ import (
|
||||
|
||||
type TestHelper struct {
|
||||
App *app.App
|
||||
originalConfig *model.Config
|
||||
tempConfigPath string
|
||||
|
||||
Client *model.Client4
|
||||
BasicUser *model.User
|
||||
@@ -73,7 +74,22 @@ func StopTestStore() {
|
||||
}
|
||||
|
||||
func setupTestHelper(enterprise bool) *TestHelper {
|
||||
options := []app.Option{app.DisableConfigWatch}
|
||||
permConfig, err := os.Open(utils.FindConfigFile("config.json"))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer permConfig.Close()
|
||||
tempConfig, err := ioutil.TempFile("", "")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
_, err = io.Copy(tempConfig, permConfig)
|
||||
tempConfig.Close()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
options := []app.Option{app.ConfigFile(tempConfig.Name()), app.DisableConfigWatch}
|
||||
if testStore != nil {
|
||||
options = append(options, app.StoreOverride(testStore))
|
||||
}
|
||||
@@ -84,9 +100,9 @@ func setupTestHelper(enterprise bool) *TestHelper {
|
||||
}
|
||||
|
||||
th := &TestHelper{
|
||||
App: a,
|
||||
App: a,
|
||||
tempConfigPath: tempConfig.Name(),
|
||||
}
|
||||
th.originalConfig = th.App.Config().Clone()
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.TeamSettings.MaxUsersPerTeam = 50
|
||||
@@ -178,11 +194,8 @@ func (me *TestHelper) TearDown() {
|
||||
|
||||
wg.Wait()
|
||||
|
||||
me.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg = *me.originalConfig
|
||||
})
|
||||
|
||||
me.App.Shutdown()
|
||||
os.Remove(me.tempConfigPath)
|
||||
|
||||
utils.EnableDebugLogForTest()
|
||||
|
||||
@@ -262,7 +275,7 @@ func (me *TestHelper) CreateTeamWithClient(client *model.Client4) *model.Team {
|
||||
team := &model.Team{
|
||||
DisplayName: "dn_" + id,
|
||||
Name: GenerateTestTeamName(),
|
||||
Email: GenerateTestEmail(),
|
||||
Email: me.GenerateTestEmail(),
|
||||
Type: model.TEAM_OPEN,
|
||||
}
|
||||
|
||||
@@ -276,7 +289,7 @@ func (me *TestHelper) CreateUserWithClient(client *model.Client4) *model.User {
|
||||
id := model.NewId()
|
||||
|
||||
user := &model.User{
|
||||
Email: GenerateTestEmail(),
|
||||
Email: me.GenerateTestEmail(),
|
||||
Username: GenerateTestUsername(),
|
||||
Nickname: "nn_" + id,
|
||||
FirstName: "f_" + id,
|
||||
@@ -451,8 +464,8 @@ func (me *TestHelper) LinkUserToTeam(user *model.User, team *model.Team) {
|
||||
utils.EnableDebugLogForTest()
|
||||
}
|
||||
|
||||
func GenerateTestEmail() string {
|
||||
if utils.Cfg.EmailSettings.SMTPServer != "dockerhost" && os.Getenv("CI_INBUCKET_PORT") == "" {
|
||||
func (me *TestHelper) GenerateTestEmail() string {
|
||||
if me.App.Config().EmailSettings.SMTPServer != "dockerhost" && os.Getenv("CI_INBUCKET_PORT") == "" {
|
||||
return strings.ToLower("success+" + model.NewId() + "@simulator.amazonses.com")
|
||||
}
|
||||
return strings.ToLower(model.NewId() + "@dockerhost")
|
||||
|
||||
Ссылка в новой задаче
Block a user