diff options
Diffstat (limited to 'app/apptestlib.go')
-rw-r--r-- | app/apptestlib.go | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/app/apptestlib.go b/app/apptestlib.go index 1ec45f0fa..09afc8f76 100644 --- a/app/apptestlib.go +++ b/app/apptestlib.go @@ -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) |