From 85efdd6b5b94a4909ab30ae4c230fb515b91b22b Mon Sep 17 00:00:00 2001 From: Chris Date: Fri, 3 Nov 2017 17:23:33 -0500 Subject: invoke config listeners when app.UpdateConfig is used (#7773) --- app/app_test.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'app/app_test.go') diff --git a/app/app_test.go b/app/app_test.go index ac39b49fe..17189956d 100644 --- a/app/app_test.go +++ b/app/app_test.go @@ -10,6 +10,9 @@ import ( l4g "github.com/alecthomas/log4go" + "github.com/stretchr/testify/assert" + + "github.com/mattermost/mattermost-server/model" "github.com/mattermost/mattermost-server/store/storetest" "github.com/mattermost/mattermost-server/utils" ) @@ -49,3 +52,23 @@ func TestAppRace(t *testing.T) { a.Shutdown() } } + +func TestUpdateConfig(t *testing.T) { + th := Setup() + defer th.TearDown() + + prev := *th.App.Config().ServiceSettings.SiteURL + defer th.App.UpdateConfig(func(cfg *model.Config) { + *cfg.ServiceSettings.SiteURL = prev + }) + + listener := utils.AddConfigListener(func(old, current *model.Config) { + assert.Equal(t, prev, *old.ServiceSettings.SiteURL) + assert.Equal(t, "foo", *current.ServiceSettings.SiteURL) + }) + defer utils.RemoveConfigListener(listener) + + th.App.UpdateConfig(func(cfg *model.Config) { + *cfg.ServiceSettings.SiteURL = "foo" + }) +} -- cgit v1.2.3-1-g7c22