diff options
author | Chris <ccbrown112@gmail.com> | 2017-11-16 08:40:26 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-16 08:40:26 -0600 |
commit | bf6bb9bce9723799991478e5aea745686045ad65 (patch) | |
tree | f9d84501c5db96563f53410aaa546aac8085157f /utils/config_test.go | |
parent | 6eb4b4604c79b0052cb7ab8ac97c9b90fa61e918 (diff) | |
download | chat-bf6bb9bce9723799991478e5aea745686045ad65.tar.gz chat-bf6bb9bce9723799991478e5aea745686045ad65.tar.bz2 chat-bf6bb9bce9723799991478e5aea745686045ad65.zip |
fix config cli option (#7850)
Diffstat (limited to 'utils/config_test.go')
-rw-r--r-- | utils/config_test.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/utils/config_test.go b/utils/config_test.go index 92d3c6fd4..157fd7fed 100644 --- a/utils/config_test.go +++ b/utils/config_test.go @@ -4,7 +4,9 @@ package utils import ( + "io/ioutil" "os" + "path/filepath" "strings" "testing" "time" @@ -21,6 +23,23 @@ func TestConfig(t *testing.T) { InitTranslations(Cfg.LocalizationSettings) } +func TestFindConfigFile(t *testing.T) { + dir, err := ioutil.TempDir("", "") + require.NoError(t, err) + defer os.RemoveAll(dir) + + path := filepath.Join(dir, "config.json") + require.NoError(t, ioutil.WriteFile(path, []byte("{}"), 0600)) + + assert.Equal(t, path, FindConfigFile(path)) + + prevDir, err := os.Getwd() + require.NoError(t, err) + defer os.Chdir(prevDir) + os.Chdir(dir) + assert.Equal(t, path, FindConfigFile(path)) +} + func TestConfigFromEnviroVars(t *testing.T) { os.Setenv("MM_TEAMSETTINGS_SITENAME", "From Enviroment") os.Setenv("MM_TEAMSETTINGS_CUSTOMBRANDTEXT", "Custom Brand") |