summaryrefslogtreecommitdiffstats
path: root/api4/post_test.go
diff options
context:
space:
mode:
authorChris <ccbrown112@gmail.com>2018-02-07 16:20:51 -0600
committerGitHub <noreply@github.com>2018-02-07 16:20:51 -0600
commit0f703a3368a0b16fcd48b474377f0dbd2144f366 (patch)
tree4928199b534de6e1d42d8057c70ebe626b237d4a /api4/post_test.go
parenteff65aa05c74e93533c2504b8141b0474011e68c (diff)
downloadchat-0f703a3368a0b16fcd48b474377f0dbd2144f366.tar.gz
chat-0f703a3368a0b16fcd48b474377f0dbd2144f366.tar.bz2
chat-0f703a3368a0b16fcd48b474377f0dbd2144f366.zip
Eliminate utils.SetLicense calls (#8217)
* eliminate utils.SetLicense calls * test fix * another test fix * more test fixes
Diffstat (limited to 'api4/post_test.go')
-rw-r--r--api4/post_test.go43
1 files changed, 2 insertions, 41 deletions
diff --git a/api4/post_test.go b/api4/post_test.go
index 6f770b70a..257918525 100644
--- a/api4/post_test.go
+++ b/api4/post_test.go
@@ -17,7 +17,6 @@ import (
"github.com/mattermost/mattermost-server/app"
"github.com/mattermost/mattermost-server/model"
- "github.com/mattermost/mattermost-server/utils"
)
func TestCreatePost(t *testing.T) {
@@ -130,20 +129,8 @@ func testCreatePostWithOutgoingHook(
team := th.BasicTeam
channel := th.BasicChannel
- enableOutgoingHooks := th.App.Config().ServiceSettings.EnableOutgoingWebhooks
- enableAdminOnlyHooks := th.App.Config().ServiceSettings.EnableOnlyAdminIntegrations
- 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.EnableOnlyAdminIntegrations = enableAdminOnlyHooks })
- th.App.SetDefaultRolesBasedOnConfig()
- 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.EnableOnlyAdminIntegrations = true })
- th.App.SetDefaultRolesBasedOnConfig()
th.App.UpdateConfig(func(cfg *model.Config) {
*cfg.ServiceSettings.AllowedUntrustedInternalConnections = "localhost 127.0.0.1"
})
@@ -489,21 +476,8 @@ func TestUpdatePost(t *testing.T) {
Client := th.Client
channel := th.BasicChannel
- isLicensed := utils.IsLicensed()
- license := utils.License()
- allowEditPost := *th.App.Config().ServiceSettings.AllowEditPost
- defer func() {
- utils.SetIsLicensed(isLicensed)
- utils.SetLicense(license)
- th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowEditPost = allowEditPost })
- th.App.SetDefaultRolesBasedOnConfig()
- }()
- utils.SetIsLicensed(true)
- utils.SetLicense(&model.License{Features: &model.Features{}})
- utils.License().Features.SetDefaults()
-
+ th.App.SetLicense(model.NewTestLicense())
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowEditPost = model.ALLOW_EDIT_POST_ALWAYS })
- th.App.SetDefaultRolesBasedOnConfig()
post := &model.Post{ChannelId: channel.Id, Message: "zz" + model.NewId() + "a"}
rpost, resp := Client.CreatePost(post)
@@ -574,21 +548,8 @@ func TestPatchPost(t *testing.T) {
Client := th.Client
channel := th.BasicChannel
- isLicensed := utils.IsLicensed()
- license := utils.License()
- allowEditPost := *th.App.Config().ServiceSettings.AllowEditPost
- defer func() {
- utils.SetIsLicensed(isLicensed)
- utils.SetLicense(license)
- th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowEditPost = allowEditPost })
- th.App.SetDefaultRolesBasedOnConfig()
- }()
- utils.SetIsLicensed(true)
- utils.SetLicense(&model.License{Features: &model.Features{}})
- utils.License().Features.SetDefaults()
-
+ th.App.SetLicense(model.NewTestLicense())
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowEditPost = model.ALLOW_EDIT_POST_ALWAYS })
- th.App.SetDefaultRolesBasedOnConfig()
post := &model.Post{
ChannelId: channel.Id,