diff options
author | Chris <ccbrown112@gmail.com> | 2017-10-18 15:36:43 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-18 15:36:43 -0700 |
commit | 8e19ba029f889519d93cf272960dce858971106c (patch) | |
tree | d8f38ac62661fb8578e2b5c3c619fe31ab29f480 /api4/plugin_test.go | |
parent | 34a87fa8f47b1447b73e3ae56866b654801b3eee (diff) | |
download | chat-8e19ba029f889519d93cf272960dce858971106c.tar.gz chat-8e19ba029f889519d93cf272960dce858971106c.tar.bz2 chat-8e19ba029f889519d93cf272960dce858971106c.zip |
Reduce utils.Cfg references (#7650)
* app.UpdateConfig method
* test fix
* another test fix
* the config override option as-was is just error prone, remove it for now
* derp
Diffstat (limited to 'api4/plugin_test.go')
-rw-r--r-- | api4/plugin_test.go | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/api4/plugin_test.go b/api4/plugin_test.go index 5051ab434..1feb1b06a 100644 --- a/api4/plugin_test.go +++ b/api4/plugin_test.go @@ -9,6 +9,7 @@ import ( "os" "testing" + "github.com/mattermost/mattermost-server/model" "github.com/mattermost/mattermost-server/utils" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -26,11 +27,11 @@ func TestPlugin(t *testing.T) { th := SetupEnterprise().InitBasic().InitSystemAdmin() defer th.TearDown() - enablePlugins := *utils.Cfg.PluginSettings.Enable + enablePlugins := *th.App.Config().PluginSettings.Enable defer func() { - *utils.Cfg.PluginSettings.Enable = enablePlugins + th.App.UpdateConfig(func(cfg *model.Config) { *cfg.PluginSettings.Enable = enablePlugins }) }() - *utils.Cfg.PluginSettings.Enable = true + th.App.UpdateConfig(func(cfg *model.Config) { *cfg.PluginSettings.Enable = true }) th.App.InitPlugins(pluginDir, webappDir) defer func() { @@ -56,11 +57,11 @@ func TestPlugin(t *testing.T) { _, resp = th.SystemAdminClient.UploadPlugin(bytes.NewReader([]byte("badfile"))) CheckBadRequestStatus(t, resp) - *utils.Cfg.PluginSettings.Enable = false + th.App.UpdateConfig(func(cfg *model.Config) { *cfg.PluginSettings.Enable = false }) _, resp = th.SystemAdminClient.UploadPlugin(file) CheckNotImplementedStatus(t, resp) - *utils.Cfg.PluginSettings.Enable = true + th.App.UpdateConfig(func(cfg *model.Config) { *cfg.PluginSettings.Enable = true }) _, resp = th.Client.UploadPlugin(file) CheckForbiddenStatus(t, resp) @@ -78,11 +79,11 @@ func TestPlugin(t *testing.T) { assert.True(t, found) // Get error cases - *utils.Cfg.PluginSettings.Enable = false + th.App.UpdateConfig(func(cfg *model.Config) { *cfg.PluginSettings.Enable = false }) _, resp = th.SystemAdminClient.GetPlugins() CheckNotImplementedStatus(t, resp) - *utils.Cfg.PluginSettings.Enable = true + th.App.UpdateConfig(func(cfg *model.Config) { *cfg.PluginSettings.Enable = true }) _, resp = th.Client.GetPlugins() CheckForbiddenStatus(t, resp) @@ -111,11 +112,11 @@ func TestPlugin(t *testing.T) { assert.False(t, ok) - *utils.Cfg.PluginSettings.Enable = false + th.App.UpdateConfig(func(cfg *model.Config) { *cfg.PluginSettings.Enable = false }) _, resp = th.SystemAdminClient.RemovePlugin(manifest.Id) CheckNotImplementedStatus(t, resp) - *utils.Cfg.PluginSettings.Enable = true + th.App.UpdateConfig(func(cfg *model.Config) { *cfg.PluginSettings.Enable = true }) _, resp = th.Client.RemovePlugin(manifest.Id) CheckForbiddenStatus(t, resp) |