MM28858 Basic framework for use of feature flags. Enviroment variable overrides. (#15544)
* Basic framework for use of feature flags. Enviroment variable overrides. * Use Apperr instead of error number increments. * Undo random viper change. * Update model/config_test.go Co-authored-by: Jesse Hallam <jesse.hallam@gmail.com> Co-authored-by: Jesse Hallam <jesse.hallam@gmail.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
61f08d397c
Коммит
e974b7b9be
@@ -14,6 +14,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/mattermost/mattermost-server/v5/config"
|
||||
"github.com/mattermost/mattermost-server/v5/mlog"
|
||||
"github.com/mattermost/mattermost-server/v5/model"
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -64,6 +65,36 @@ func TestGetPing(t *testing.T) {
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
t.Run("ping feature flag test", func(t *testing.T) {
|
||||
resp, appErr := th.Client.DoApiGet(th.Client.GetSystemRoute()+"/ping", "")
|
||||
require.Nil(t, appErr)
|
||||
require.Equal(t, http.StatusOK, resp.StatusCode)
|
||||
respBytes, err := ioutil.ReadAll(resp.Body)
|
||||
require.Nil(t, err)
|
||||
respString := string(respBytes)
|
||||
require.NotContains(t, respString, "TestFeatureFlag")
|
||||
|
||||
// Run the enviroment variable override code to test
|
||||
os.Setenv("MM_FEATUREFLAGS_TESTFEATURE", "testvalue")
|
||||
defer os.Unsetenv("MM_FEATUREFLAGS_TESTFEATURE")
|
||||
memoryStore, err := config.NewMemoryStore()
|
||||
require.Nil(t, err)
|
||||
retrievedConfig := memoryStore.Get()
|
||||
|
||||
// replace config with generated config
|
||||
oldConfig := th.App.Config().Clone()
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg = *retrievedConfig })
|
||||
|
||||
resp, appErr = th.Client.DoApiGet(th.Client.GetSystemRoute()+"/ping", "")
|
||||
require.Nil(t, appErr)
|
||||
require.Equal(t, http.StatusOK, resp.StatusCode)
|
||||
respBytes, err = ioutil.ReadAll(resp.Body)
|
||||
require.Nil(t, err)
|
||||
respString = string(respBytes)
|
||||
require.Contains(t, respString, "testvalue")
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg = *oldConfig })
|
||||
})
|
||||
}
|
||||
|
||||
func TestGetAudits(t *testing.T) {
|
||||
|
||||
Ссылка в новой задаче
Block a user