summaryrefslogtreecommitdiffstats
path: root/api/post_test.go
diff options
context:
space:
mode:
authorChris <ccbrown112@gmail.com>2017-10-23 02:39:51 -0700
committerGitHub <noreply@github.com>2017-10-23 02:39:51 -0700
commit08b7b1c4144f18a9dbf52bfe0eb9182f2b4eba4a (patch)
tree6f2613d6032cfb6d357925c0f64cc02920694549 /api/post_test.go
parentfd6192473b3c2a91d1520e366d931063e359a67d (diff)
downloadchat-08b7b1c4144f18a9dbf52bfe0eb9182f2b4eba4a.tar.gz
chat-08b7b1c4144f18a9dbf52bfe0eb9182f2b4eba4a.tar.bz2
chat-08b7b1c4144f18a9dbf52bfe0eb9182f2b4eba4a.zip
Reduce cfg boilerplate (#7689)
* reduce cfg boilerplate * fix compile error * user test fix * another test fix * simplify diagnostics / testing
Diffstat (limited to 'api/post_test.go')
-rw-r--r--api/post_test.go32
1 files changed, 2 insertions, 30 deletions
diff --git a/api/post_test.go b/api/post_test.go
index 901a7c6d0..342bd03ae 100644
--- a/api/post_test.go
+++ b/api/post_test.go
@@ -241,16 +241,8 @@ func testCreatePostWithOutgoingHook(
user := th.SystemAdminUser
channel := th.CreateChannel(Client, team)
- enableOutgoingHooks := th.App.Config().ServiceSettings.EnableOutgoingWebhooks
- allowedInternalConnections := *th.App.Config().ServiceSettings.AllowedUntrustedInternalConnections
- defer func() {
- th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOutgoingWebhooks = enableOutgoingHooks })
- th.App.UpdateConfig(func(cfg *model.Config) {
- cfg.ServiceSettings.AllowedUntrustedInternalConnections = &allowedInternalConnections
- })
- }()
- th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOutgoingWebhooks = true })
th.App.UpdateConfig(func(cfg *model.Config) {
+ cfg.ServiceSettings.EnableOutgoingWebhooks = true
*cfg.ServiceSettings.AllowedUntrustedInternalConnections = "localhost 127.0.0.1"
})
@@ -406,13 +398,6 @@ func TestUpdatePost(t *testing.T) {
Client := th.BasicClient
channel1 := th.BasicChannel
- allowEditPost := *th.App.Config().ServiceSettings.AllowEditPost
- postEditTimeLimit := *th.App.Config().ServiceSettings.PostEditTimeLimit
- defer func() {
- th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowEditPost = allowEditPost })
- th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.PostEditTimeLimit = postEditTimeLimit })
- }()
-
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowEditPost = model.ALLOW_EDIT_POST_ALWAYS })
post1 := &model.Post{ChannelId: channel1.Id, Message: "zz" + model.NewId() + "a"}
@@ -981,11 +966,6 @@ func TestDeletePosts(t *testing.T) {
channel1 := th.BasicChannel
team1 := th.BasicTeam
- restrictPostDelete := *th.App.Config().ServiceSettings.RestrictPostDelete
- defer func() {
- th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.RestrictPostDelete = restrictPostDelete })
- utils.SetDefaultRolesBasedOnConfig()
- }()
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.RestrictPostDelete = model.PERMISSIONS_DELETE_POST_ALL })
utils.SetDefaultRolesBasedOnConfig()
@@ -1482,16 +1462,8 @@ func TestGetOpenGraphMetadata(t *testing.T) {
Client := th.BasicClient
- enableLinkPreviews := *th.App.Config().ServiceSettings.EnableLinkPreviews
- allowedInternalConnections := *th.App.Config().ServiceSettings.AllowedUntrustedInternalConnections
- defer func() {
- th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableLinkPreviews = enableLinkPreviews })
- th.App.UpdateConfig(func(cfg *model.Config) {
- cfg.ServiceSettings.AllowedUntrustedInternalConnections = &allowedInternalConnections
- })
- }()
- th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableLinkPreviews = true })
th.App.UpdateConfig(func(cfg *model.Config) {
+ *cfg.ServiceSettings.EnableLinkPreviews = true
*cfg.ServiceSettings.AllowedUntrustedInternalConnections = "localhost 127.0.0.1"
})