Files
mattermost/utils/config_test.go
Harrison Healey fb6f2a123c PLT-5860 Updated copyright date (#6058)
* PLT-5860 Updated copyright date in about modal

* PLT-5860 Updated copyright notice in JSX files

* PLT-5860 Updated copyright notice in go files

* Fixed misc copyright dates

* Fixed component snapshots
2017-04-12 08:27:57 -04:00

62 lines
1.5 KiB
Go

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
package utils
import (
"os"
"testing"
)
func TestConfig(t *testing.T) {
TranslationsPreInit()
LoadConfig("config.json")
InitTranslations(Cfg.LocalizationSettings)
}
func TestConfigFromEnviroVars(t *testing.T) {
os.Setenv("MM_TEAMSETTINGS_SITENAME", "From Enviroment")
os.Setenv("MM_TEAMSETTINGS_CUSTOMBRANDTEXT", "Custom Brand")
os.Setenv("MM_SERVICESETTINGS_ENABLECOMMANDS", "false")
os.Setenv("MM_SERVICESETTINGS_READTIMEOUT", "400")
TranslationsPreInit()
EnableConfigFromEnviromentVars()
LoadConfig("config.json")
if Cfg.TeamSettings.SiteName != "From Enviroment" {
t.Fatal("Couldn't read config from enviroment var")
}
if *Cfg.TeamSettings.CustomBrandText != "Custom Brand" {
t.Fatal("Couldn't read config from enviroment var")
}
if *Cfg.ServiceSettings.EnableCommands != false {
t.Fatal("Couldn't read config from enviroment var")
}
if *Cfg.ServiceSettings.ReadTimeout != 400 {
t.Fatal("Couldn't read config from enviroment var")
}
os.Unsetenv("MM_TEAMSETTINGS_SITENAME")
os.Unsetenv("MM_TEAMSETTINGS_CUSTOMBRANDTEXT")
os.Unsetenv("MM_SERVICESETTINGS_ENABLECOMMANDS")
os.Unsetenv("MM_SERVICESETTINGS_READTIMEOUT")
Cfg.TeamSettings.SiteName = "Mattermost"
*Cfg.ServiceSettings.SiteURL = ""
*Cfg.ServiceSettings.EnableCommands = true
*Cfg.ServiceSettings.ReadTimeout = 300
SaveConfig(CfgFileName, Cfg)
LoadConfig("config.json")
if Cfg.TeamSettings.SiteName != "Mattermost" {
t.Fatal("should have been reset")
}
}