quintodrome/tests/init_tests.go

37 lines
731 B
Go
Raw Normal View History

2016-02-27 14:42:08 -09:00
package tests
import (
"os"
"path/filepath"
"runtime"
2017-04-01 06:59:31 -08:00
"sync"
2016-02-27 14:42:08 -09:00
"testing"
2016-03-08 14:33:35 -09:00
"github.com/astaxie/beego"
2017-04-01 05:47:14 -08:00
"github.com/cloudsonic/sonic-server/conf"
"github.com/cloudsonic/sonic-server/utils"
2016-02-27 14:42:08 -09:00
)
2017-04-01 06:59:31 -08:00
var initSync sync.Once
2016-02-27 14:42:08 -09:00
func Init(t *testing.T, skipOnShort bool) {
if skipOnShort && testing.Short() {
t.Skip("skipping test in short mode.")
}
_, file, _, _ := runtime.Caller(0)
appPath, _ := filepath.Abs(filepath.Join(filepath.Dir(file), ".."))
2017-04-01 06:59:31 -08:00
confPath, _ := filepath.Abs(filepath.Join(appPath, "tests", "sonic-test.toml"))
conf.LoadFromFile(confPath)
initSync.Do(func() {
beego.TestBeegoInit(appPath)
})
2016-02-27 14:42:08 -09:00
noLog := os.Getenv("NOLOG")
if noLog != "" {
beego.SetLevel(beego.LevelError)
}
2016-03-08 14:33:35 -09:00
utils.Graph.Finalize()
2016-02-27 14:42:08 -09:00
}