summaryrefslogtreecommitdiffstats
path: root/app/apptestlib.go
diff options
context:
space:
mode:
authorChris <ccbrown112@gmail.com>2018-01-17 12:38:37 -0600
committerHarrison Healey <harrisonmhealey@gmail.com>2018-01-17 13:38:37 -0500
commit4e6cc846a618ecef5c101727bbd03f6674044ab7 (patch)
tree1fc093b4b338acf34180c93f30a32de50e17d089 /app/apptestlib.go
parentdce061630530c467966378ae3c5adbcf4a09e34f (diff)
downloadchat-4e6cc846a618ecef5c101727bbd03f6674044ab7.tar.gz
chat-4e6cc846a618ecef5c101727bbd03f6674044ab7.tar.bz2
chat-4e6cc846a618ecef5c101727bbd03f6674044ab7.zip
Finally remove utils.Cfg (#8113)
* finally remove utils.Cfg * fix compile error * another test compilation fix
Diffstat (limited to 'app/apptestlib.go')
-rw-r--r--app/apptestlib.go29
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)