summaryrefslogtreecommitdiffstats
path: root/api4/post_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 /api4/post_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 'api4/post_test.go')
-rw-r--r--api4/post_test.go34
1 files changed, 19 insertions, 15 deletions
diff --git a/api4/post_test.go b/api4/post_test.go
index 27e6d6458..3a410f2b4 100644
--- a/api4/post_test.go
+++ b/api4/post_test.go
@@ -124,19 +124,23 @@ func testCreatePostWithOutgoingHook(
team := th.BasicTeam
channel := th.BasicChannel
- enableOutgoingHooks := utils.Cfg.ServiceSettings.EnableOutgoingWebhooks
- enableAdminOnlyHooks := utils.Cfg.ServiceSettings.EnableOnlyAdminIntegrations
- allowedInternalConnections := *utils.Cfg.ServiceSettings.AllowedUntrustedInternalConnections
+ enableOutgoingHooks := th.App.Config().ServiceSettings.EnableOutgoingWebhooks
+ enableAdminOnlyHooks := th.App.Config().ServiceSettings.EnableOnlyAdminIntegrations
+ allowedInternalConnections := *th.App.Config().ServiceSettings.AllowedUntrustedInternalConnections
defer func() {
- utils.Cfg.ServiceSettings.EnableOutgoingWebhooks = enableOutgoingHooks
- utils.Cfg.ServiceSettings.EnableOnlyAdminIntegrations = enableAdminOnlyHooks
+ th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOutgoingWebhooks = enableOutgoingHooks })
+ th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOnlyAdminIntegrations = enableAdminOnlyHooks })
utils.SetDefaultRolesBasedOnConfig()
- utils.Cfg.ServiceSettings.AllowedUntrustedInternalConnections = &allowedInternalConnections
+ th.App.UpdateConfig(func(cfg *model.Config) {
+ cfg.ServiceSettings.AllowedUntrustedInternalConnections = &allowedInternalConnections
+ })
}()
- utils.Cfg.ServiceSettings.EnableOutgoingWebhooks = true
- *utils.Cfg.ServiceSettings.EnableOnlyAdminIntegrations = true
+ th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOutgoingWebhooks = true })
+ th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOnlyAdminIntegrations = true })
utils.SetDefaultRolesBasedOnConfig()
- *utils.Cfg.ServiceSettings.AllowedUntrustedInternalConnections = "localhost 127.0.0.1"
+ th.App.UpdateConfig(func(cfg *model.Config) {
+ *cfg.ServiceSettings.AllowedUntrustedInternalConnections = "localhost 127.0.0.1"
+ })
var hook *model.OutgoingWebhook
var post *model.Post
@@ -375,18 +379,18 @@ func TestUpdatePost(t *testing.T) {
isLicensed := utils.IsLicensed()
license := utils.License()
- allowEditPost := *utils.Cfg.ServiceSettings.AllowEditPost
+ allowEditPost := *th.App.Config().ServiceSettings.AllowEditPost
defer func() {
utils.SetIsLicensed(isLicensed)
utils.SetLicense(license)
- *utils.Cfg.ServiceSettings.AllowEditPost = allowEditPost
+ th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowEditPost = allowEditPost })
utils.SetDefaultRolesBasedOnConfig()
}()
utils.SetIsLicensed(true)
utils.SetLicense(&model.License{Features: &model.Features{}})
utils.License().Features.SetDefaults()
- *utils.Cfg.ServiceSettings.AllowEditPost = model.ALLOW_EDIT_POST_ALWAYS
+ th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowEditPost = model.ALLOW_EDIT_POST_ALWAYS })
utils.SetDefaultRolesBasedOnConfig()
post := &model.Post{ChannelId: channel.Id, Message: "zz" + model.NewId() + "a"}
@@ -455,18 +459,18 @@ func TestPatchPost(t *testing.T) {
isLicensed := utils.IsLicensed()
license := utils.License()
- allowEditPost := *utils.Cfg.ServiceSettings.AllowEditPost
+ allowEditPost := *th.App.Config().ServiceSettings.AllowEditPost
defer func() {
utils.SetIsLicensed(isLicensed)
utils.SetLicense(license)
- *utils.Cfg.ServiceSettings.AllowEditPost = allowEditPost
+ th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowEditPost = allowEditPost })
utils.SetDefaultRolesBasedOnConfig()
}()
utils.SetIsLicensed(true)
utils.SetLicense(&model.License{Features: &model.Features{}})
utils.License().Features.SetDefaults()
- *utils.Cfg.ServiceSettings.AllowEditPost = model.ALLOW_EDIT_POST_ALWAYS
+ th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowEditPost = model.ALLOW_EDIT_POST_ALWAYS })
utils.SetDefaultRolesBasedOnConfig()
post := &model.Post{