From ab99f0656fabed8a62a8c6340be7d538cc7bf8d9 Mon Sep 17 00:00:00 2001 From: George Goldberg Date: Mon, 17 Sep 2018 15:51:26 +0100 Subject: MM-11781: Basic Data Export Command Line. (#9296) * MM-11781: Basic Data Export Command Line. * ChannelStore new unit tests. * TeamStore new unit tests. * Unit test for new UserStore function. * Unit tests for post store new methods. * Review fixes. * Fix duplicate command name. --- cmd/mattermost/commands/message_export_test.go | 66 -------------------------- 1 file changed, 66 deletions(-) delete mode 100644 cmd/mattermost/commands/message_export_test.go (limited to 'cmd/mattermost/commands/message_export_test.go') diff --git a/cmd/mattermost/commands/message_export_test.go b/cmd/mattermost/commands/message_export_test.go deleted file mode 100644 index 89ef45a6a..000000000 --- a/cmd/mattermost/commands/message_export_test.go +++ /dev/null @@ -1,66 +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/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, RunCommand(t, "--config", configPath, "export", "schedule")) -} - -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, RunCommand(t, "--config", configPath, "--format", "not_actiance", "export", "schedule")) -} - -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, RunCommand(t, "--config", configPath, "--format", "actiance", "--exportFrom", "-1", "export", "schedule")) -} - -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, RunCommand(t, "--config", configPath, "--format", "actiance", "--exportFrom", "0", "--timeoutSeconds", "-1", "export", "schedule")) -} - -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 -} -- cgit v1.2.3-1-g7c22