- refactor test init flow

This commit is contained in:
gazebo
2019-03-20 22:28:51 +08:00
parent 120e0dde6c
commit 15c703b469
17 changed files with 76 additions and 129 deletions

View File

@@ -0,0 +1,22 @@
package testinit1
import (
"path/filepath"
"runtime"
"git.rosy.net.cn/jx-callback/globals"
"git.rosy.net.cn/jx-callback/globals/beegodb"
"github.com/astaxie/beego"
)
func Init() {
_, file, _, _ := runtime.Caller(0)
apppath, _ := filepath.Abs(filepath.Dir(filepath.Join(file, ".."+string(filepath.Separator)+".."+string(filepath.Separator))))
beego.TestBeegoInit(apppath)
globals.SugarLogger.Infof("testinit RunMode=%s", beego.BConfig.RunMode)
beego.BConfig.RunMode = "dev" // InitBeegoBeforeTest会将runmode设置为test
globals.Init()
beegodb.Init()
}