summaryrefslogtreecommitdiffstats
path: root/api4
diff options
context:
space:
mode:
authorChris <ccbrown112@gmail.com>2017-09-12 14:12:29 -0500
committerJoram Wilander <jwawilander@gmail.com>2017-09-12 15:12:29 -0400
commit4731b8f9b993536ed61dbc065e161e8994253f0d (patch)
tree140e7407ef793204dd94e1b58a725e836c75b2b5 /api4
parentb066b6df138e88e75cb40f1ec3e58fbd13e61909 (diff)
downloadchat-4731b8f9b993536ed61dbc065e161e8994253f0d.tar.gz
chat-4731b8f9b993536ed61dbc065e161e8994253f0d.tar.bz2
chat-4731b8f9b993536ed61dbc065e161e8994253f0d.zip
fix plugin test (#7436)
* fix plugin test * ugh. global state * Fix plugin test * Fix TestDeleteChannel * Remove plugin config listener when shutting down
Diffstat (limited to 'api4')
-rw-r--r--api4/apitestlib.go8
-rw-r--r--api4/channel_test.go3
-rw-r--r--api4/plugin_test.go14
3 files changed, 15 insertions, 10 deletions
diff --git a/api4/apitestlib.go b/api4/apitestlib.go
index d98683d32..9538eb99c 100644
--- a/api4/apitestlib.go
+++ b/api4/apitestlib.go
@@ -58,9 +58,6 @@ func setupTestHelper(enterprise bool) *TestHelper {
*utils.Cfg.RateLimitSettings.Enable = false
utils.Cfg.EmailSettings.SendEmailNotifications = true
utils.DisableDebugLogForTest()
- if enterprise {
- utils.License().Features.SetDefaults()
- }
th.App.NewServer()
th.App.InitStores()
th.App.Srv.Router = NewRouter()
@@ -74,6 +71,11 @@ func setupTestHelper(enterprise bool) *TestHelper {
*utils.Cfg.TeamSettings.EnableOpenServer = true
}
+ utils.SetIsLicensed(enterprise)
+ if enterprise {
+ utils.License().Features.SetDefaults()
+ }
+
if jobs.Srv.Store == nil {
jobs.Srv.Store = th.App.Srv.Store
}
diff --git a/api4/channel_test.go b/api4/channel_test.go
index 57b760178..7237eb47a 100644
--- a/api4/channel_test.go
+++ b/api4/channel_test.go
@@ -876,6 +876,8 @@ func TestDeleteChannel(t *testing.T) {
_, resp = th.SystemAdminClient.DeleteChannel(publicChannel5.Id)
CheckNoError(t, resp)
+ th = Setup().InitBasic().InitSystemAdmin()
+
isLicensed := utils.IsLicensed()
license := utils.License()
restrictPublicChannel := *utils.Cfg.TeamSettings.RestrictPublicChannelManagement
@@ -894,7 +896,6 @@ func TestDeleteChannel(t *testing.T) {
utils.License().Features.SetDefaults()
utils.SetDefaultRolesBasedOnConfig()
- th = Setup().InitBasic().InitSystemAdmin()
Client = th.Client
team = th.BasicTeam
user = th.BasicUser
diff --git a/api4/plugin_test.go b/api4/plugin_test.go
index 898649f56..f92e58ea0 100644
--- a/api4/plugin_test.go
+++ b/api4/plugin_test.go
@@ -26,17 +26,21 @@ func TestPlugin(t *testing.T) {
os.RemoveAll(webappDir)
}()
- th := Setup().InitBasic().InitSystemAdmin()
+ th := SetupEnterprise().InitBasic().InitSystemAdmin()
defer TearDown()
- th.App.InitPlugins(pluginDir, webappDir)
-
enablePlugins := *utils.Cfg.PluginSettings.Enable
defer func() {
*utils.Cfg.PluginSettings.Enable = enablePlugins
}()
*utils.Cfg.PluginSettings.Enable = true
+ th.App.InitPlugins(pluginDir, webappDir)
+ defer func() {
+ th.App.ShutDownPlugins()
+ th.App.PluginEnv = nil
+ }()
+
path, _ := utils.FindDir("tests")
file, err := os.Open(path + "/testplugin.tar.gz")
if err != nil {
@@ -108,7 +112,5 @@ func TestPlugin(t *testing.T) {
CheckForbiddenStatus(t, resp)
_, resp = th.SystemAdminClient.RemovePlugin("bad.id")
- CheckNotFoundStatus(t, resp)
-
- th.App.PluginEnv = nil
+ CheckBadRequestStatus(t, resp)
}