summaryrefslogtreecommitdiffstats
path: root/api4/commands_test.go
diff options
context:
space:
mode:
authorCarlos Tadeu Panato Junior <ctadeu@gmail.com>2018-07-11 12:58:16 +0200
committerGitHub <noreply@github.com>2018-07-11 12:58:16 +0200
commit7ed712f938588491da35b1d04b7f44700975c70b (patch)
tree45586bdbefda64408c0cc1c3e34e7fd8d1b2004a /api4/commands_test.go
parent7c08ff99864721956d1496b8114fa54dd33569f0 (diff)
downloadchat-7ed712f938588491da35b1d04b7f44700975c70b.tar.gz
chat-7ed712f938588491da35b1d04b7f44700975c70b.tar.bz2
chat-7ed712f938588491da35b1d04b7f44700975c70b.zip
Restore config after finisht the test case (#9085)
Diffstat (limited to 'api4/commands_test.go')
-rw-r--r--api4/commands_test.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/api4/commands_test.go b/api4/commands_test.go
index cb960c608..66238df7d 100644
--- a/api4/commands_test.go
+++ b/api4/commands_test.go
@@ -163,6 +163,11 @@ func TestLoadTestHelpCommands(t *testing.T) {
Client := th.Client
channel := th.BasicChannel
+ enableTesting := th.App.Config().ServiceSettings.EnableTesting
+ defer func() {
+ th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableTesting = enableTesting })
+ }()
+
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableTesting = true })
rs := Client.Must(Client.ExecuteCommand(channel.Id, "/test help")).(*model.CommandResponse)
@@ -180,6 +185,11 @@ func TestLoadTestSetupCommands(t *testing.T) {
Client := th.Client
channel := th.BasicChannel
+ enableTesting := th.App.Config().ServiceSettings.EnableTesting
+ defer func() {
+ th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableTesting = enableTesting })
+ }()
+
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableTesting = true })
rs := Client.Must(Client.ExecuteCommand(channel.Id, "/test setup fuzz 1 1 1")).(*model.CommandResponse)
@@ -197,6 +207,11 @@ func TestLoadTestUsersCommands(t *testing.T) {
Client := th.Client
channel := th.BasicChannel
+ enableTesting := th.App.Config().ServiceSettings.EnableTesting
+ defer func() {
+ th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableTesting = enableTesting })
+ }()
+
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableTesting = true })
rs := Client.Must(Client.ExecuteCommand(channel.Id, "/test users fuzz 1 2")).(*model.CommandResponse)
@@ -214,6 +229,11 @@ func TestLoadTestChannelsCommands(t *testing.T) {
Client := th.Client
channel := th.BasicChannel
+ enableTesting := th.App.Config().ServiceSettings.EnableTesting
+ defer func() {
+ th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableTesting = enableTesting })
+ }()
+
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableTesting = true })
rs := Client.Must(Client.ExecuteCommand(channel.Id, "/test channels fuzz 1 2")).(*model.CommandResponse)
@@ -231,6 +251,11 @@ func TestLoadTestPostsCommands(t *testing.T) {
Client := th.Client
channel := th.BasicChannel
+ enableTesting := th.App.Config().ServiceSettings.EnableTesting
+ defer func() {
+ th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableTesting = enableTesting })
+ }()
+
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableTesting = true })
rs := Client.Must(Client.ExecuteCommand(channel.Id, "/test posts fuzz 2 3 2")).(*model.CommandResponse)