diff options
author | George Goldberg <george@gberg.me> | 2018-03-13 13:36:23 +0000 |
---|---|---|
committer | George Goldberg <george@gberg.me> | 2018-03-13 13:36:23 +0000 |
commit | fadcdd271a68b38571b75d1d38ab023f940ac83a (patch) | |
tree | 7f413edd35401b54b2f4eb4a687da1ac273bcd4b /cmd/commands/config_flag_test.go | |
parent | b66e4bc932ed76c1cfd2b5f4ec0cfce70cd9fbb4 (diff) | |
parent | f2d26801b9647715fb43af873354d8def753868b (diff) | |
download | chat-fadcdd271a68b38571b75d1d38ab023f940ac83a.tar.gz chat-fadcdd271a68b38571b75d1d38ab023f940ac83a.tar.bz2 chat-fadcdd271a68b38571b75d1d38ab023f940ac83a.zip |
Merge branch 'master' into advanced-permissions-phase-1
Diffstat (limited to 'cmd/commands/config_flag_test.go')
-rw-r--r-- | cmd/commands/config_flag_test.go | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/cmd/commands/config_flag_test.go b/cmd/commands/config_flag_test.go new file mode 100644 index 000000000..8d284ab73 --- /dev/null +++ b/cmd/commands/config_flag_test.go @@ -0,0 +1,42 @@ +// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +package commands + +import ( + "io/ioutil" + "os" + "path/filepath" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/mattermost/mattermost-server/cmd" + "github.com/mattermost/mattermost-server/utils" +) + +func TestConfigFlag(t *testing.T) { + dir, err := ioutil.TempDir("", "") + require.NoError(t, err) + defer os.RemoveAll(dir) + + utils.TranslationsPreInit() + config, _, err := utils.LoadConfig("config.json") + require.Nil(t, err) + configPath := filepath.Join(dir, "foo.json") + require.NoError(t, ioutil.WriteFile(configPath, []byte(config.ToJson()), 0600)) + + i18n, ok := utils.FindDir("i18n") + require.True(t, ok) + require.NoError(t, utils.CopyDir(i18n, filepath.Join(dir, "i18n"))) + + prevDir, err := os.Getwd() + require.NoError(t, err) + defer os.Chdir(prevDir) + os.Chdir(dir) + + require.Error(t, cmd.RunCommand(t, "version")) + cmd.CheckCommand(t, "--config", "foo.json", "version") + cmd.CheckCommand(t, "--config", "./foo.json", "version") + cmd.CheckCommand(t, "--config", configPath, "version") +} |