diff options
author | Chris <ccbrown112@gmail.com> | 2017-10-18 15:36:43 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-18 15:36:43 -0700 |
commit | 8e19ba029f889519d93cf272960dce858971106c (patch) | |
tree | d8f38ac62661fb8578e2b5c3c619fe31ab29f480 /api/emoji_test.go | |
parent | 34a87fa8f47b1447b73e3ae56866b654801b3eee (diff) | |
download | chat-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 'api/emoji_test.go')
-rw-r--r-- | api/emoji_test.go | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/api/emoji_test.go b/api/emoji_test.go index 5ee034e9c..8aae047d4 100644 --- a/api/emoji_test.go +++ b/api/emoji_test.go @@ -22,11 +22,11 @@ func TestGetEmoji(t *testing.T) { Client := th.BasicClient - EnableCustomEmoji := *utils.Cfg.ServiceSettings.EnableCustomEmoji + EnableCustomEmoji := *th.App.Config().ServiceSettings.EnableCustomEmoji defer func() { - *utils.Cfg.ServiceSettings.EnableCustomEmoji = EnableCustomEmoji + th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableCustomEmoji = EnableCustomEmoji }) }() - *utils.Cfg.ServiceSettings.EnableCustomEmoji = true + th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableCustomEmoji = true }) emojis := []*model.Emoji{ { @@ -102,11 +102,11 @@ func TestCreateEmoji(t *testing.T) { Client := th.BasicClient - EnableCustomEmoji := *utils.Cfg.ServiceSettings.EnableCustomEmoji + EnableCustomEmoji := *th.App.Config().ServiceSettings.EnableCustomEmoji defer func() { - *utils.Cfg.ServiceSettings.EnableCustomEmoji = EnableCustomEmoji + th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableCustomEmoji = EnableCustomEmoji }) }() - *utils.Cfg.ServiceSettings.EnableCustomEmoji = false + th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableCustomEmoji = false }) emoji := &model.Emoji{ CreatorId: th.BasicUser.Id, @@ -118,7 +118,7 @@ func TestCreateEmoji(t *testing.T) { t.Fatal("shouldn't be able to create an emoji when they're disabled") } - *utils.Cfg.ServiceSettings.EnableCustomEmoji = true + th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableCustomEmoji = true }) // try to create a valid gif emoji when they're enabled if emojiResult, err := Client.CreateEmoji(emoji, utils.CreateTestGif(t, 10, 10), "image.gif"); err != nil { @@ -226,11 +226,11 @@ func TestDeleteEmoji(t *testing.T) { Client := th.BasicClient - EnableCustomEmoji := *utils.Cfg.ServiceSettings.EnableCustomEmoji + EnableCustomEmoji := *th.App.Config().ServiceSettings.EnableCustomEmoji defer func() { - *utils.Cfg.ServiceSettings.EnableCustomEmoji = EnableCustomEmoji + th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableCustomEmoji = EnableCustomEmoji }) }() - *utils.Cfg.ServiceSettings.EnableCustomEmoji = false + th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableCustomEmoji = false }) emoji1 := createTestEmoji(t, th.App, &model.Emoji{ CreatorId: th.BasicUser.Id, @@ -241,7 +241,7 @@ func TestDeleteEmoji(t *testing.T) { t.Fatal("shouldn't have been able to delete an emoji when they're disabled") } - *utils.Cfg.ServiceSettings.EnableCustomEmoji = true + th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableCustomEmoji = true }) if deleted, err := Client.DeleteEmoji(emoji1.Id); err != nil { t.Fatal(err) @@ -286,14 +286,18 @@ func TestGetEmojiImage(t *testing.T) { Client := th.BasicClient - EnableCustomEmoji := *utils.Cfg.ServiceSettings.EnableCustomEmoji - RestrictCustomEmojiCreation := *utils.Cfg.ServiceSettings.RestrictCustomEmojiCreation + EnableCustomEmoji := *th.App.Config().ServiceSettings.EnableCustomEmoji + RestrictCustomEmojiCreation := *th.App.Config().ServiceSettings.RestrictCustomEmojiCreation defer func() { - *utils.Cfg.ServiceSettings.EnableCustomEmoji = EnableCustomEmoji - *utils.Cfg.ServiceSettings.RestrictCustomEmojiCreation = RestrictCustomEmojiCreation + th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableCustomEmoji = EnableCustomEmoji }) + th.App.UpdateConfig(func(cfg *model.Config) { + *cfg.ServiceSettings.RestrictCustomEmojiCreation = RestrictCustomEmojiCreation + }) }() - *utils.Cfg.ServiceSettings.EnableCustomEmoji = true - *utils.Cfg.ServiceSettings.RestrictCustomEmojiCreation = model.RESTRICT_EMOJI_CREATION_ALL + th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableCustomEmoji = true }) + th.App.UpdateConfig(func(cfg *model.Config) { + *cfg.ServiceSettings.RestrictCustomEmojiCreation = model.RESTRICT_EMOJI_CREATION_ALL + }) emoji1 := &model.Emoji{ CreatorId: th.BasicUser.Id, @@ -302,13 +306,13 @@ func TestGetEmojiImage(t *testing.T) { emoji1 = Client.MustGeneric(Client.CreateEmoji(emoji1, utils.CreateTestGif(t, 10, 10), "image.gif")).(*model.Emoji) defer func() { Client.MustGeneric(Client.DeleteEmoji(emoji1.Id)) }() - *utils.Cfg.ServiceSettings.EnableCustomEmoji = false + th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableCustomEmoji = false }) if _, err := Client.DoApiGet(Client.GetCustomEmojiImageUrl(emoji1.Id), "", ""); err == nil { t.Fatal("should've failed to get emoji image when disabled") } - *utils.Cfg.ServiceSettings.EnableCustomEmoji = true + th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableCustomEmoji = true }) if resp, err := Client.DoApiGet(Client.GetCustomEmojiImageUrl(emoji1.Id), "", ""); err != nil { t.Fatal(err) |