diff options
author | Christopher Speller <crspeller@gmail.com> | 2018-05-17 12:40:40 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-17 12:40:40 -0700 |
commit | 11cbb597471127c1b29e78e6cad0a1a4d93ea24c (patch) | |
tree | 0eceb950872c7234348f0b41d4492073908840d0 /cmd/commands/message_export_test.go | |
parent | 1f6c271b3bedd6656ae7155714423b1b39a669c1 (diff) | |
download | chat-11cbb597471127c1b29e78e6cad0a1a4d93ea24c.tar.gz chat-11cbb597471127c1b29e78e6cad0a1a4d93ea24c.tar.bz2 chat-11cbb597471127c1b29e78e6cad0a1a4d93ea24c.zip |
Renaming platform binary to mattermost. (#8801)
Diffstat (limited to 'cmd/commands/message_export_test.go')
-rw-r--r-- | cmd/commands/message_export_test.go | 67 |
1 files changed, 0 insertions, 67 deletions
diff --git a/cmd/commands/message_export_test.go b/cmd/commands/message_export_test.go deleted file mode 100644 index bd0e049d6..000000000 --- a/cmd/commands/message_export_test.go +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (c) 2016-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/model" - "github.com/mattermost/mattermost-server/utils" -) - -// There are no tests that actually run the Message Export job, because it can take a long time to complete depending -// on the size of the database that the config is pointing to. As such, these tests just ensure that the CLI command -// fails fast if invalid flags are supplied - -func TestMessageExportNotEnabled(t *testing.T) { - configPath := writeTempConfig(t, false) - defer os.RemoveAll(filepath.Dir(configPath)) - - // should fail fast because the feature isn't enabled - require.Error(t, cmd.RunCommand(t, "--config", configPath, "export")) -} - -func TestMessageExportInvalidFormat(t *testing.T) { - configPath := writeTempConfig(t, true) - defer os.RemoveAll(filepath.Dir(configPath)) - - // should fail fast because format isn't supported - require.Error(t, cmd.RunCommand(t, "--config", configPath, "--format", "not_actiance", "export")) -} - -func TestMessageExportNegativeExportFrom(t *testing.T) { - configPath := writeTempConfig(t, true) - defer os.RemoveAll(filepath.Dir(configPath)) - - // should fail fast because export from must be a valid timestamp - require.Error(t, cmd.RunCommand(t, "--config", configPath, "--format", "actiance", "--exportFrom", "-1", "export")) -} - -func TestMessageExportNegativeTimeoutSeconds(t *testing.T) { - configPath := writeTempConfig(t, true) - defer os.RemoveAll(filepath.Dir(configPath)) - - // should fail fast because timeout seconds must be a positive int - require.Error(t, cmd.RunCommand(t, "--config", configPath, "--format", "actiance", "--exportFrom", "0", "--timeoutSeconds", "-1", "export")) -} - -func writeTempConfig(t *testing.T, isMessageExportEnabled bool) string { - dir, err := ioutil.TempDir("", "") - require.NoError(t, err) - - utils.TranslationsPreInit() - config, _, _, appErr := utils.LoadConfig("config.json") - require.Nil(t, appErr) - config.MessageExportSettings.EnableExport = model.NewBool(isMessageExportEnabled) - configPath := filepath.Join(dir, "foo.json") - require.NoError(t, ioutil.WriteFile(configPath, []byte(config.ToJson()), 0600)) - - return configPath -} |