[MM-14400] Programmatically generate default.json (#10551)
* create/update config.json using go generate * added default config generator added config-reset to Jenkins and make package, updated defaults to consider 'isNew' flag * corrections after code review * fixed Config.isValid to handle empty encryption keys * fixed Config.isValid to handle empty encryption keys * fixed Config.isValid to handle empty encryption keys * isUpdate now only checks for nil * Addressed review comments, added unit testing for default config generator * err shadowing * license * provide output file for config generator via ENV variable, since go generate doesn't support arguments and we need two output paths (config-reset and package) * cleanup * proper defaults for PushNotificationServer and SendPushNotifications * corrected generating defaults for TrustedProxyIPHeader to be consistent with default.json in master * Check for empty SiteURL as well as nil * corrected SiteURL settings and checking * crazy typos fixed * corrected tests to newly expected values * relaxed the checks * fixed formatting
Этот коммит содержится в:
коммит произвёл
Jesse Hallam
родитель
978ee13262
Коммит
6a42ad2af5
@@ -122,7 +122,7 @@ func TestFileStoreNew(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
defer fs.Close()
|
||||
|
||||
assert.Equal(t, model.SERVICE_SETTINGS_DEFAULT_SITE_URL, *fs.Get().ServiceSettings.SiteURL)
|
||||
assert.Equal(t, "", *fs.Get().ServiceSettings.SiteURL)
|
||||
assertFileNotEqualsConfig(t, testConfig, path)
|
||||
})
|
||||
|
||||
@@ -175,7 +175,7 @@ func TestFileStoreNew(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
defer fs.Close()
|
||||
|
||||
assert.Equal(t, model.SERVICE_SETTINGS_DEFAULT_SITE_URL, *fs.Get().ServiceSettings.SiteURL)
|
||||
assert.Equal(t, "", *fs.Get().ServiceSettings.SiteURL)
|
||||
assertFileNotEqualsConfig(t, testConfig, filepath.Join("config", path))
|
||||
})
|
||||
}
|
||||
@@ -257,7 +257,7 @@ func TestFileStoreSet(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, oldCfg, retCfg)
|
||||
|
||||
assert.Equal(t, model.SERVICE_SETTINGS_DEFAULT_SITE_URL, *fs.Get().ServiceSettings.SiteURL)
|
||||
assert.Equal(t, "", *fs.Get().ServiceSettings.SiteURL)
|
||||
})
|
||||
|
||||
t.Run("desanitization required", func(t *testing.T) {
|
||||
@@ -296,7 +296,7 @@ func TestFileStoreSet(t *testing.T) {
|
||||
assert.EqualError(t, err, "new configuration is invalid: Config.IsValid: model.config.is_valid.site_url.app_error, ")
|
||||
}
|
||||
|
||||
assert.Equal(t, model.SERVICE_SETTINGS_DEFAULT_SITE_URL, *fs.Get().ServiceSettings.SiteURL)
|
||||
assert.Equal(t, "", *fs.Get().ServiceSettings.SiteURL)
|
||||
})
|
||||
|
||||
t.Run("read-only", func(t *testing.T) {
|
||||
@@ -314,7 +314,7 @@ func TestFileStoreSet(t *testing.T) {
|
||||
assert.Equal(t, config.ErrReadOnlyConfiguration, errors.Cause(err))
|
||||
}
|
||||
|
||||
assert.Equal(t, model.SERVICE_SETTINGS_DEFAULT_SITE_URL, *fs.Get().ServiceSettings.SiteURL)
|
||||
assert.Equal(t, "", *fs.Get().ServiceSettings.SiteURL)
|
||||
})
|
||||
|
||||
t.Run("persist failed", func(t *testing.T) {
|
||||
@@ -335,7 +335,7 @@ func TestFileStoreSet(t *testing.T) {
|
||||
assert.True(t, strings.HasPrefix(err.Error(), "failed to persist: failed to write file"))
|
||||
}
|
||||
|
||||
assert.Equal(t, model.SERVICE_SETTINGS_DEFAULT_SITE_URL, *fs.Get().ServiceSettings.SiteURL)
|
||||
assert.Equal(t, "", *fs.Get().ServiceSettings.SiteURL)
|
||||
})
|
||||
|
||||
t.Run("listeners notified", func(t *testing.T) {
|
||||
|
||||
Ссылка в новой задаче
Block a user