summaryrefslogtreecommitdiffstats
path: root/api/command_test.go
diff options
context:
space:
mode:
authorChris <ccbrown112@gmail.com>2017-10-18 15:36:43 -0700
committerGitHub <noreply@github.com>2017-10-18 15:36:43 -0700
commit8e19ba029f889519d93cf272960dce858971106c (patch)
treed8f38ac62661fb8578e2b5c3c619fe31ab29f480 /api/command_test.go
parent34a87fa8f47b1447b73e3ae56866b654801b3eee (diff)
downloadchat-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 'api/command_test.go')
-rw-r--r--api/command_test.go51
1 files changed, 26 insertions, 25 deletions
diff --git a/api/command_test.go b/api/command_test.go
index 948193852..7eadca124 100644
--- a/api/command_test.go
+++ b/api/command_test.go
@@ -10,7 +10,6 @@ import (
"time"
"github.com/mattermost/mattermost-server/model"
- "github.com/mattermost/mattermost-server/utils"
)
func TestListCommands(t *testing.T) {
@@ -45,11 +44,11 @@ func TestCreateCommand(t *testing.T) {
user := th.SystemAdminUser
team := th.SystemAdminTeam
- enableCommands := *utils.Cfg.ServiceSettings.EnableCommands
+ enableCommands := *th.App.Config().ServiceSettings.EnableCommands
defer func() {
- utils.Cfg.ServiceSettings.EnableCommands = &enableCommands
+ th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableCommands = &enableCommands })
}()
- *utils.Cfg.ServiceSettings.EnableCommands = true
+ th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableCommands = true })
cmd1 := &model.Command{
CreatorId: user.Id,
@@ -108,11 +107,11 @@ func TestListTeamCommands(t *testing.T) {
Client := th.SystemAdminClient
- enableCommands := *utils.Cfg.ServiceSettings.EnableCommands
+ enableCommands := *th.App.Config().ServiceSettings.EnableCommands
defer func() {
- utils.Cfg.ServiceSettings.EnableCommands = &enableCommands
+ th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableCommands = &enableCommands })
}()
- *utils.Cfg.ServiceSettings.EnableCommands = true
+ th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableCommands = true })
cmd1 := &model.Command{URL: "http://nowhere.com", Method: model.COMMAND_METHOD_POST, Trigger: "trigger"}
cmd1 = Client.Must(Client.CreateCommand(cmd1)).Data.(*model.Command)
@@ -136,11 +135,11 @@ func TestUpdateCommand(t *testing.T) {
user := th.SystemAdminUser
team := th.SystemAdminTeam
- enableCommands := *utils.Cfg.ServiceSettings.EnableCommands
+ enableCommands := *th.App.Config().ServiceSettings.EnableCommands
defer func() {
- utils.Cfg.ServiceSettings.EnableCommands = &enableCommands
+ th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableCommands = &enableCommands })
}()
- *utils.Cfg.ServiceSettings.EnableCommands = true
+ th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableCommands = true })
cmd1 := &model.Command{
CreatorId: user.Id,
@@ -175,11 +174,11 @@ func TestRegenToken(t *testing.T) {
Client := th.SystemAdminClient
- enableCommands := *utils.Cfg.ServiceSettings.EnableCommands
+ enableCommands := *th.App.Config().ServiceSettings.EnableCommands
defer func() {
- utils.Cfg.ServiceSettings.EnableCommands = &enableCommands
+ th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableCommands = &enableCommands })
}()
- *utils.Cfg.ServiceSettings.EnableCommands = true
+ th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableCommands = true })
cmd := &model.Command{URL: "http://nowhere.com", Method: model.COMMAND_METHOD_POST, Trigger: "trigger"}
cmd = Client.Must(Client.CreateCommand(cmd)).Data.(*model.Command)
@@ -202,14 +201,14 @@ func TestDeleteCommand(t *testing.T) {
Client := th.SystemAdminClient
- enableCommands := *utils.Cfg.ServiceSettings.EnableCommands
- onlyAdminIntegration := *utils.Cfg.ServiceSettings.EnableOnlyAdminIntegrations
+ enableCommands := *th.App.Config().ServiceSettings.EnableCommands
+ onlyAdminIntegration := *th.App.Config().ServiceSettings.EnableOnlyAdminIntegrations
defer func() {
- *utils.Cfg.ServiceSettings.EnableCommands = enableCommands
- *utils.Cfg.ServiceSettings.EnableOnlyAdminIntegrations = onlyAdminIntegration
+ th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableCommands = enableCommands })
+ th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOnlyAdminIntegrations = onlyAdminIntegration })
}()
- *utils.Cfg.ServiceSettings.EnableCommands = true
- *utils.Cfg.ServiceSettings.EnableOnlyAdminIntegrations = false
+ th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableCommands = true })
+ th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOnlyAdminIntegrations = false })
cmd := &model.Command{URL: "http://nowhere.com", Method: model.COMMAND_METHOD_POST, Trigger: "trigger"}
cmd = Client.Must(Client.CreateCommand(cmd)).Data.(*model.Command)
@@ -248,14 +247,16 @@ func TestTestCommand(t *testing.T) {
Client := th.SystemAdminClient
channel1 := th.SystemAdminChannel
- enableCommands := *utils.Cfg.ServiceSettings.EnableCommands
- allowedInternalConnections := *utils.Cfg.ServiceSettings.AllowedUntrustedInternalConnections
+ enableCommands := *th.App.Config().ServiceSettings.EnableCommands
+ allowedInternalConnections := *th.App.Config().ServiceSettings.AllowedUntrustedInternalConnections
defer func() {
- utils.Cfg.ServiceSettings.EnableCommands = &enableCommands
- utils.Cfg.ServiceSettings.AllowedUntrustedInternalConnections = &allowedInternalConnections
+ th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableCommands = &enableCommands })
+ th.App.UpdateConfig(func(cfg *model.Config) {
+ cfg.ServiceSettings.AllowedUntrustedInternalConnections = &allowedInternalConnections
+ })
}()
- *utils.Cfg.ServiceSettings.EnableCommands = true
- *utils.Cfg.ServiceSettings.AllowedUntrustedInternalConnections = "localhost"
+ th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableCommands = true })
+ th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowedUntrustedInternalConnections = "localhost" })
cmd1 := &model.Command{
URL: fmt.Sprintf("http://localhost:%v", th.App.Srv.ListenAddr.Port) + model.API_URL_SUFFIX_V3 + "/teams/command_test",