diff options
Diffstat (limited to 'utils/config_test.go')
-rw-r--r-- | utils/config_test.go | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/utils/config_test.go b/utils/config_test.go index 278f24251..80ab05ffe 100644 --- a/utils/config_test.go +++ b/utils/config_test.go @@ -335,6 +335,9 @@ func TestConfigFromEnviroVars(t *testing.T) { "TeamSettings": { "SiteName": "Mattermost", "CustomBrandText": "" + }, + "SupportSettings": { + "TermsOfServiceLink": "https://about.mattermost.com/default-terms/" } }` @@ -447,6 +450,28 @@ func TestConfigFromEnviroVars(t *testing.T) { } } }) + + t.Run("empty string setting", func(t *testing.T) { + os.Setenv("MM_SUPPORTSETTINGS_TERMSOFSERVICELINK", "") + defer os.Unsetenv("MM_SUPPORTSETTINGS_TERMSOFSERVICELINK") + + cfg, envCfg, err := ReadConfig(strings.NewReader(config), true) + require.Nil(t, err) + + if *cfg.SupportSettings.TermsOfServiceLink != "" { + t.Fatal("Couldn't read empty TermsOfServiceLink from environment var") + } + + if supportSettings, ok := envCfg["SupportSettings"]; !ok { + t.Fatal("SupportSettings is missing from envConfig") + } else if supportSettingsAsMap, ok := supportSettings.(map[string]interface{}); !ok { + t.Fatal("SupportSettings is not a map in envConfig") + } else { + if termsOfServiceLinkInEnv, ok := supportSettingsAsMap["TermsOfServiceLink"].(bool); !ok || !termsOfServiceLinkInEnv { + t.Fatal("TermsOfServiceLink should be in envConfig") + } + } + }) } func TestValidateLocales(t *testing.T) { |