* reduce cfg boilerplate

* fix compile error

* user test fix

* another test fix

* simplify diagnostics / testing
Этот коммит содержится в:
Chris
2017-10-23 02:39:51 -07:00
коммит произвёл GitHub
родитель fd6192473b
Коммит 08b7b1c414
13 изменённых файлов: 279 добавлений и 689 удалений

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

@@ -12,6 +12,9 @@ import (
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/utils"
)
@@ -29,21 +32,15 @@ func newTestServer() (chan string, *httptest.Server) {
}
func TestPluginSetting(t *testing.T) {
before := utils.Cfg.PluginSettings.Plugins
utils.Cfg.PluginSettings.Plugins = map[string]interface{}{
"test": map[string]string{
"foo": "bar",
settings := &model.PluginSettings{
Plugins: map[string]interface{}{
"test": map[string]string{
"foo": "bar",
},
},
}
defer func() {
utils.Cfg.PluginSettings.Plugins = before
}()
if pluginSetting("test", "foo", "asd") != "bar" {
t.Fatal()
}
if pluginSetting("test", "qwe", "asd") != "asd" {
t.Fatal()
}
assert.Equal(t, "bar", pluginSetting(settings, "test", "foo", "asd"))
assert.Equal(t, "asd", pluginSetting(settings, "test", "qwe", "asd"))
}
func TestDiagnostics(t *testing.T) {