MM-22619: check for nil plugins environment (#13901)

* MM-22619: check for nil plugins environment

Check if plugins were disabled before attempting to collect metrics and emit telemetry for same.

Fixes: https://mattermost.atlassian.net/browse/MM-22619

* Update app/diagnostics_test.go
Этот коммит содержится в:
Jesse Hallam
2020-02-15 18:46:26 -04:00
коммит произвёл GitHub
родитель bd487418f7
Коммит 9a51c73f64
3 изменённых файлов: 82 добавлений и 20 удалений

Просмотреть файл

@@ -33,7 +33,7 @@ type TestHelper struct {
tempWorkspace string
}
func setupTestHelper(enterprise bool, tb testing.TB) *TestHelper {
func setupTestHelper(enterprise bool, tb testing.TB, configSet func(*model.Config)) *TestHelper {
store := mainHelper.GetStore()
store.DropAllTables()
@@ -48,6 +48,9 @@ func setupTestHelper(enterprise bool, tb testing.TB) *TestHelper {
}
config := memoryStore.Get()
if configSet != nil {
configSet(config)
}
*config.PluginSettings.Directory = filepath.Join(tempWorkspace, "plugins")
*config.PluginSettings.ClientDirectory = filepath.Join(tempWorkspace, "webapp")
memoryStore.Set(config)
@@ -105,11 +108,15 @@ func setupTestHelper(enterprise bool, tb testing.TB) *TestHelper {
}
func SetupEnterprise(tb testing.TB) *TestHelper {
return setupTestHelper(true, tb)
return setupTestHelper(true, tb, nil)
}
func Setup(tb testing.TB) *TestHelper {
return setupTestHelper(false, tb)
return setupTestHelper(false, tb, nil)
}
func SetupWithCustomConfig(tb testing.TB, configSet func(*model.Config)) *TestHelper {
return setupTestHelper(false, tb, configSet)
}
func (me *TestHelper) InitBasic() *TestHelper {