Finally remove utils.Cfg (#8113)
* finally remove utils.Cfg * fix compile error * another test compilation fix
Этот коммит содержится в:
коммит произвёл
Harrison Healey
родитель
dce0616305
Коммит
4e6cc846a6
@@ -5,6 +5,7 @@ package app
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -29,8 +30,9 @@ type TestHelper struct {
|
||||
BasicChannel *model.Channel
|
||||
BasicPost *model.Post
|
||||
|
||||
tempWorkspace string
|
||||
pluginHooks map[string]plugin.Hooks
|
||||
tempConfigPath string
|
||||
tempWorkspace string
|
||||
pluginHooks map[string]plugin.Hooks
|
||||
}
|
||||
|
||||
type persistentTestStore struct {
|
||||
@@ -57,7 +59,22 @@ func StopTestStore() {
|
||||
}
|
||||
|
||||
func setupTestHelper(enterprise bool) *TestHelper {
|
||||
options := []Option{DisableConfigWatch}
|
||||
permConfig, err := os.Open(utils.FindConfigFile("config.json"))
|
||||
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)
|
||||
}
|
||||
|
||||
options := []Option{ConfigFile(tempConfig.Name()), DisableConfigWatch}
|
||||
if testStore != nil {
|
||||
options = append(options, StoreOverride(testStore))
|
||||
}
|
||||
@@ -68,8 +85,9 @@ func setupTestHelper(enterprise bool) *TestHelper {
|
||||
}
|
||||
|
||||
th := &TestHelper{
|
||||
App: a,
|
||||
pluginHooks: make(map[string]plugin.Hooks),
|
||||
App: a,
|
||||
pluginHooks: make(map[string]plugin.Hooks),
|
||||
tempConfigPath: tempConfig.Name(),
|
||||
}
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.MaxUsersPerTeam = 50 })
|
||||
@@ -232,6 +250,7 @@ func (me *TestHelper) LinkUserToTeam(user *model.User, team *model.Team) {
|
||||
|
||||
func (me *TestHelper) TearDown() {
|
||||
me.App.Shutdown()
|
||||
os.Remove(me.tempConfigPath)
|
||||
if err := recover(); err != nil {
|
||||
StopTestStore()
|
||||
panic(err)
|
||||
|
||||
Ссылка в новой задаче
Block a user