From b718618fbc1d79648b6a92e623b778181623d0a1 Mon Sep 17 00:00:00 2001 From: Jesse Hallam Date: Fri, 20 Mar 2020 16:34:12 -0300 Subject: [PATCH] Minor model/config.go coverage improvements (#14094) * add TestConfigEnableDeveloper * remove dead code --- model/config.go | 4 ---- model/config_test.go | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/model/config.go b/model/config.go index 82db6eb528..7b2b911aa3 100644 --- a/model/config.go +++ b/model/config.go @@ -415,10 +415,6 @@ func (s *ServiceSettings) SetDefaults(isUpdate bool) { s.EnableIncomingWebhooks = NewBool(true) } - if s.EnableIncomingWebhooks == nil { - s.EnableIncomingWebhooks = NewBool(true) - } - if s.EnableOutgoingWebhooks == nil { s.EnableOutgoingWebhooks = NewBool(true) } diff --git a/model/config_test.go b/model/config_test.go index 1ca5596f78..78a098dfd1 100644 --- a/model/config_test.go +++ b/model/config_test.go @@ -66,6 +66,31 @@ func TestConfigEmptySiteName(t *testing.T) { require.Equal(t, *c1.TeamSettings.SiteName, TEAM_SETTINGS_DEFAULT_SITE_NAME) } +func TestConfigEnableDeveloper(t *testing.T) { + testCases := []struct { + Description string + EnableDeveloper *bool + ExpectedSiteURL string + }{ + {"enable developer is true", NewBool(true), SERVICE_SETTINGS_DEFAULT_SITE_URL}, + {"enable developer is false", NewBool(false), ""}, + {"enable developer is nil", nil, ""}, + } + + for _, testCase := range testCases { + t.Run(testCase.Description, func(t *testing.T) { + c1 := Config{ + ServiceSettings: ServiceSettings{ + EnableDeveloper: testCase.EnableDeveloper, + }, + } + c1.SetDefaults() + + require.Equal(t, testCase.ExpectedSiteURL, *c1.ServiceSettings.SiteURL) + }) + } +} + func TestConfigDefaultFileSettingsDirectory(t *testing.T) { c1 := Config{} c1.SetDefaults()