From 8e19ba029f889519d93cf272960dce858971106c Mon Sep 17 00:00:00 2001 From: Chris Date: Wed, 18 Oct 2017 15:36:43 -0700 Subject: 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 --- api/command_loadtest_test.go | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) (limited to 'api/command_loadtest_test.go') diff --git a/api/command_loadtest_test.go b/api/command_loadtest_test.go index 346b3379e..62545ae64 100644 --- a/api/command_loadtest_test.go +++ b/api/command_loadtest_test.go @@ -9,7 +9,6 @@ import ( "time" "github.com/mattermost/mattermost-server/model" - "github.com/mattermost/mattermost-server/utils" ) func TestLoadTestHelpCommands(t *testing.T) { @@ -20,12 +19,12 @@ func TestLoadTestHelpCommands(t *testing.T) { channel := th.BasicChannel // enable testing to use /test but don't save it since we don't want to overwrite config.json - enableTesting := utils.Cfg.ServiceSettings.EnableTesting + enableTesting := th.App.Config().ServiceSettings.EnableTesting defer func() { - utils.Cfg.ServiceSettings.EnableTesting = enableTesting + th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableTesting = enableTesting }) }() - utils.Cfg.ServiceSettings.EnableTesting = true + th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableTesting = true }) rs := Client.Must(Client.Command(channel.Id, "/test help")).Data.(*model.CommandResponse) if !strings.Contains(rs.Text, "Mattermost testing commands to help") { @@ -43,12 +42,12 @@ func TestLoadTestSetupCommands(t *testing.T) { channel := th.BasicChannel // enable testing to use /test but don't save it since we don't want to overwrite config.json - enableTesting := utils.Cfg.ServiceSettings.EnableTesting + enableTesting := th.App.Config().ServiceSettings.EnableTesting defer func() { - utils.Cfg.ServiceSettings.EnableTesting = enableTesting + th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableTesting = enableTesting }) }() - utils.Cfg.ServiceSettings.EnableTesting = true + th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableTesting = true }) rs := Client.Must(Client.Command(channel.Id, "/test setup fuzz 1 1 1")).Data.(*model.CommandResponse) if rs.Text != "Created enviroment" { @@ -66,12 +65,12 @@ func TestLoadTestUsersCommands(t *testing.T) { channel := th.BasicChannel // enable testing to use /test but don't save it since we don't want to overwrite config.json - enableTesting := utils.Cfg.ServiceSettings.EnableTesting + enableTesting := th.App.Config().ServiceSettings.EnableTesting defer func() { - utils.Cfg.ServiceSettings.EnableTesting = enableTesting + th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableTesting = enableTesting }) }() - utils.Cfg.ServiceSettings.EnableTesting = true + th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableTesting = true }) rs := Client.Must(Client.Command(channel.Id, "/test users fuzz 1 2")).Data.(*model.CommandResponse) if rs.Text != "Added users" { @@ -89,12 +88,12 @@ func TestLoadTestChannelsCommands(t *testing.T) { channel := th.BasicChannel // enable testing to use /test but don't save it since we don't want to overwrite config.json - enableTesting := utils.Cfg.ServiceSettings.EnableTesting + enableTesting := th.App.Config().ServiceSettings.EnableTesting defer func() { - utils.Cfg.ServiceSettings.EnableTesting = enableTesting + th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableTesting = enableTesting }) }() - utils.Cfg.ServiceSettings.EnableTesting = true + th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableTesting = true }) rs := Client.Must(Client.Command(channel.Id, "/test channels fuzz 1 2")).Data.(*model.CommandResponse) if rs.Text != "Added channels" { @@ -112,12 +111,12 @@ func TestLoadTestPostsCommands(t *testing.T) { channel := th.BasicChannel // enable testing to use /test but don't save it since we don't want to overwrite config.json - enableTesting := utils.Cfg.ServiceSettings.EnableTesting + enableTesting := th.App.Config().ServiceSettings.EnableTesting defer func() { - utils.Cfg.ServiceSettings.EnableTesting = enableTesting + th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableTesting = enableTesting }) }() - utils.Cfg.ServiceSettings.EnableTesting = true + th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableTesting = true }) rs := Client.Must(Client.Command(channel.Id, "/test posts fuzz 2 3 2")).Data.(*model.CommandResponse) if rs.Text != "Added posts" { -- cgit v1.2.3-1-g7c22