diff options
author | Jesús Espino <jespinog@gmail.com> | 2018-02-07 18:05:23 +0100 |
---|---|---|
committer | Jesús Espino <jespinog@gmail.com> | 2018-02-07 18:05:23 +0100 |
commit | a04b02081a77497ecfc7a5ae9ffb0ca28404dd0e (patch) | |
tree | 985cb699d278f68522b08b60b1e7b84e0bd243fc /model/config_test.go | |
parent | 7941c30117efe1b957ac0458c2f0479e3824196d (diff) | |
parent | 7bd298ceaa24c0721e0acd65692cb2d1ca4983f3 (diff) | |
download | chat-a04b02081a77497ecfc7a5ae9ffb0ca28404dd0e.tar.gz chat-a04b02081a77497ecfc7a5ae9ffb0ca28404dd0e.tar.bz2 chat-a04b02081a77497ecfc7a5ae9ffb0ca28404dd0e.zip |
Merge remote-tracking branch 'origin/master' into advanced-permissions-phase-1
Diffstat (limited to 'model/config_test.go')
-rw-r--r-- | model/config_test.go | 84 |
1 files changed, 83 insertions, 1 deletions
diff --git a/model/config_test.go b/model/config_test.go index ceede6be4..919f73fd7 100644 --- a/model/config_test.go +++ b/model/config_test.go @@ -36,6 +36,38 @@ func TestConfigDefaultFileSettingsS3SSE(t *testing.T) { } } +func TestConfigDefaultServiceSettingsExperimentalGroupUnreadChannels(t *testing.T) { + c1 := Config{} + c1.SetDefaults() + + if *c1.ServiceSettings.ExperimentalGroupUnreadChannels != GROUP_UNREAD_CHANNELS_DISABLED { + t.Fatal("ServiceSettings.ExperimentalGroupUnreadChannels should default to 'disabled'") + } + + // This setting was briefly a boolean, so ensure that those values still work as expected + c1 = Config{ + ServiceSettings: ServiceSettings{ + ExperimentalGroupUnreadChannels: NewString("1"), + }, + } + c1.SetDefaults() + + if *c1.ServiceSettings.ExperimentalGroupUnreadChannels != GROUP_UNREAD_CHANNELS_DEFAULT_ON { + t.Fatal("ServiceSettings.ExperimentalGroupUnreadChannels should set true to 'default on'") + } + + c1 = Config{ + ServiceSettings: ServiceSettings{ + ExperimentalGroupUnreadChannels: NewString("0"), + }, + } + c1.SetDefaults() + + if *c1.ServiceSettings.ExperimentalGroupUnreadChannels != GROUP_UNREAD_CHANNELS_DISABLED { + t.Fatal("ServiceSettings.ExperimentalGroupUnreadChannels should set false to 'disabled'") + } +} + func TestMessageExportSettingsIsValidEnableExportNotSet(t *testing.T) { fs := &FileSettings{} mes := &MessageExportSettings{} @@ -104,12 +136,44 @@ func TestMessageExportSettingsIsValidBatchSizeInvalid(t *testing.T) { require.Error(t, mes.isValid(*fs)) } -func TestMessageExportSettingsIsValid(t *testing.T) { +func TestMessageExportSettingsIsValidExportFormatInvalid(t *testing.T) { + fs := &FileSettings{ + DriverName: NewString("foo"), // bypass file location check + } + mes := &MessageExportSettings{ + EnableExport: NewBool(true), + ExportFromTimestamp: NewInt64(0), + DailyRunTime: NewString("15:04"), + BatchSize: NewInt(100), + } + + // should fail fast because export format isn't set + require.Error(t, mes.isValid(*fs)) +} + +func TestMessageExportSettingsIsValidGlobalRelayEmailAddressInvalid(t *testing.T) { + fs := &FileSettings{ + DriverName: NewString("foo"), // bypass file location check + } + mes := &MessageExportSettings{ + EnableExport: NewBool(true), + ExportFormat: NewString(COMPLIANCE_EXPORT_TYPE_GLOBALRELAY), + ExportFromTimestamp: NewInt64(0), + DailyRunTime: NewString("15:04"), + BatchSize: NewInt(100), + } + + // should fail fast because global relay email address isn't set + require.Error(t, mes.isValid(*fs)) +} + +func TestMessageExportSettingsIsValidActiance(t *testing.T) { fs := &FileSettings{ DriverName: NewString("foo"), // bypass file location check } mes := &MessageExportSettings{ EnableExport: NewBool(true), + ExportFormat: NewString(COMPLIANCE_EXPORT_TYPE_ACTIANCE), ExportFromTimestamp: NewInt64(0), DailyRunTime: NewString("15:04"), BatchSize: NewInt(100), @@ -119,6 +183,23 @@ func TestMessageExportSettingsIsValid(t *testing.T) { require.Nil(t, mes.isValid(*fs)) } +func TestMessageExportSettingsIsValidGlobalRelay(t *testing.T) { + fs := &FileSettings{ + DriverName: NewString("foo"), // bypass file location check + } + mes := &MessageExportSettings{ + EnableExport: NewBool(true), + ExportFormat: NewString(COMPLIANCE_EXPORT_TYPE_GLOBALRELAY), + ExportFromTimestamp: NewInt64(0), + DailyRunTime: NewString("15:04"), + BatchSize: NewInt(100), + GlobalRelayEmailAddress: NewString("test@mattermost.com"), + } + + // should pass because everything is valid + require.Nil(t, mes.isValid(*fs)) +} + func TestMessageExportSetDefaults(t *testing.T) { mes := &MessageExportSettings{} mes.SetDefaults() @@ -127,6 +208,7 @@ func TestMessageExportSetDefaults(t *testing.T) { require.Equal(t, "01:00", *mes.DailyRunTime) require.Equal(t, int64(0), *mes.ExportFromTimestamp) require.Equal(t, 10000, *mes.BatchSize) + require.Equal(t, COMPLIANCE_EXPORT_TYPE_ACTIANCE, *mes.ExportFormat) } func TestMessageExportSetDefaultsExportEnabledExportFromTimestampNil(t *testing.T) { |