MM-14143 config cleanup final (#10374)
* TestGetLicenseFileFromDisk: avoid using fileutils.FindConfigFile * config: abstract config-related file access, extend memory store * simplify config validate to avoid file knowledge * fix relative file tests * cluster: fix ConfigChanged event The old and new configurations were swapped when notifying the enterprise code of configuration changes, creating needless instability in propagating config updates across a cluster. * config/database: ignore duplicates * test cleanup * remove unnecessary Save() in test
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
3716918c57
Коммит
1e462da2d4
@@ -4,16 +4,14 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/mattermost/mattermost-server/app"
|
||||
"github.com/mattermost/mattermost-server/config"
|
||||
"github.com/mattermost/mattermost-server/mlog"
|
||||
"github.com/mattermost/mattermost-server/model"
|
||||
"github.com/mattermost/mattermost-server/utils"
|
||||
"github.com/mattermost/mattermost-server/utils/fileutils"
|
||||
)
|
||||
|
||||
type TestHelper struct {
|
||||
@@ -27,31 +25,21 @@ type TestHelper struct {
|
||||
|
||||
SystemAdminUser *model.User
|
||||
|
||||
tempConfigPath string
|
||||
tempWorkspace string
|
||||
tempWorkspace string
|
||||
}
|
||||
|
||||
func setupTestHelper(enterprise bool) *TestHelper {
|
||||
store := mainHelper.GetStore()
|
||||
store.DropAllTables()
|
||||
|
||||
permConfig, err := os.Open(fileutils.FindConfigFile("config.json"))
|
||||
memoryStore, err := config.NewMemoryStore()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer permConfig.Close()
|
||||
tempConfig, err := ioutil.TempFile("", "")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
_, err = io.Copy(tempConfig, permConfig)
|
||||
tempConfig.Close()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
panic("failed to initialize memory store: " + err.Error())
|
||||
}
|
||||
|
||||
options := []app.Option{app.Config(tempConfig.Name(), false)}
|
||||
options = append(options, app.StoreOverride(store))
|
||||
var options []app.Option
|
||||
options = append(options, app.ConfigStore(memoryStore))
|
||||
options = append(options, app.StoreOverride(mainHelper.Store))
|
||||
|
||||
s, err := app.NewServer(options...)
|
||||
if err != nil {
|
||||
@@ -59,9 +47,8 @@ func setupTestHelper(enterprise bool) *TestHelper {
|
||||
}
|
||||
|
||||
th := &TestHelper{
|
||||
App: s.FakeApp(),
|
||||
Server: s,
|
||||
tempConfigPath: tempConfig.Name(),
|
||||
App: s.FakeApp(),
|
||||
Server: s,
|
||||
}
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.MaxUsersPerTeam = 50 })
|
||||
@@ -259,7 +246,6 @@ func (me *TestHelper) AddUserToChannel(user *model.User, channel *model.Channel)
|
||||
|
||||
func (me *TestHelper) TearDown() {
|
||||
me.Server.Shutdown()
|
||||
os.Remove(me.tempConfigPath)
|
||||
if err := recover(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user