mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
PLT-3456 Fix Errors while starting the server (#3445)
* PLT-3456 AppErrors that are triggered before translations are loaded crash server or produce bad error messages. * Fixing tests
This commit is contained in:
committed by
Christopher Speller
parent
5dfa4fb629
commit
2305b2597f
@@ -29,6 +29,7 @@ type TestHelper struct {
|
||||
|
||||
func SetupEnterprise() *TestHelper {
|
||||
if Srv == nil {
|
||||
utils.TranslationsPreInit()
|
||||
utils.LoadConfig("config.json")
|
||||
utils.InitTranslations(utils.Cfg.LocalizationSettings)
|
||||
utils.Cfg.TeamSettings.MaxUsersPerTeam = 50
|
||||
@@ -49,6 +50,7 @@ func SetupEnterprise() *TestHelper {
|
||||
|
||||
func Setup() *TestHelper {
|
||||
if Srv == nil {
|
||||
utils.TranslationsPreInit()
|
||||
utils.LoadConfig("config.json")
|
||||
utils.InitTranslations(utils.Cfg.LocalizationSettings)
|
||||
utils.Cfg.TeamSettings.MaxUsersPerTeam = 50
|
||||
|
||||
@@ -74,12 +74,12 @@ func doLoadConfig(filename string) (err string) {
|
||||
err = fmt.Sprintf("%v", r)
|
||||
}
|
||||
}()
|
||||
utils.TranslationsPreInit()
|
||||
utils.LoadConfig(filename)
|
||||
return ""
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
parseCmds()
|
||||
|
||||
if errstr := doLoadConfig(flagConfigFile); errstr != "" {
|
||||
|
||||
@@ -15,6 +15,7 @@ var store Store
|
||||
|
||||
func Setup() {
|
||||
if store == nil {
|
||||
utils.TranslationsPreInit()
|
||||
utils.LoadConfig("config.json")
|
||||
utils.InitTranslations(utils.Cfg.LocalizationSettings)
|
||||
store = NewSqlStore()
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
)
|
||||
|
||||
func TestConfig(t *testing.T) {
|
||||
TranslationsPreInit()
|
||||
LoadConfig("config.json")
|
||||
InitTranslations(Cfg.LocalizationSettings)
|
||||
}
|
||||
|
||||
@@ -15,9 +15,16 @@ var T i18n.TranslateFunc
|
||||
var locales map[string]string = make(map[string]string)
|
||||
var settings model.LocalizationSettings
|
||||
|
||||
// this functions loads translations from filesystem
|
||||
// and assign english while loading server config
|
||||
func TranslationsPreInit() {
|
||||
InitTranslationsWithDir("i18n")
|
||||
T = TfuncWithFallback("en")
|
||||
}
|
||||
|
||||
func InitTranslations(localizationSettings model.LocalizationSettings) {
|
||||
settings = localizationSettings
|
||||
InitTranslationsWithDir("i18n")
|
||||
T = GetTranslationsBySystemLocale()
|
||||
}
|
||||
|
||||
func InitTranslationsWithDir(dir string) {
|
||||
@@ -30,8 +37,6 @@ func InitTranslationsWithDir(dir string) {
|
||||
i18n.MustLoadTranslationFile(i18nDirectory + filename)
|
||||
}
|
||||
}
|
||||
|
||||
T = GetTranslationsBySystemLocale()
|
||||
}
|
||||
|
||||
func GetTranslationsBySystemLocale() i18n.TranslateFunc {
|
||||
|
||||
@@ -79,14 +79,14 @@ func TestConnection(config *model.Config) {
|
||||
|
||||
conn, err1 := connectToSMTPServer(config)
|
||||
if err1 != nil {
|
||||
l4g.Error(T("utils.mail.test.configured.error"), err1.Message, err1.DetailedError)
|
||||
l4g.Error(T("utils.mail.test.configured.error"), T(err1.Message), err1.DetailedError)
|
||||
return
|
||||
}
|
||||
defer conn.Close()
|
||||
|
||||
c, err2 := newSMTPClient(conn, config)
|
||||
if err2 != nil {
|
||||
l4g.Error(T("utils.mail.test.configured.error"), err2.Message, err2.DetailedError)
|
||||
l4g.Error(T("utils.mail.test.configured.error"), T(err2.Message), err2.DetailedError)
|
||||
return
|
||||
}
|
||||
defer c.Quit()
|
||||
|
||||
@@ -20,6 +20,7 @@ var URL string
|
||||
|
||||
func Setup() {
|
||||
if api.Srv == nil {
|
||||
utils.TranslationsPreInit()
|
||||
utils.LoadConfig("config.json")
|
||||
utils.InitTranslations(utils.Cfg.LocalizationSettings)
|
||||
api.NewServer()
|
||||
|
||||
Reference in New Issue
Block a user