navidrome/tests/init_tests.go

36 lines
731 B
Go
Raw Normal View History

2016-02-27 18:42:08 -05:00
package tests
import (
"os"
"path/filepath"
"runtime"
2017-04-01 10:59:31 -04:00
"sync"
2016-02-27 18:42:08 -05:00
"testing"
2016-03-08 18:33:35 -05:00
"github.com/astaxie/beego"
2017-04-01 09:47:14 -04:00
"github.com/cloudsonic/sonic-server/conf"
"github.com/cloudsonic/sonic-server/utils"
2016-02-27 18:42:08 -05:00
)
2017-04-01 10:59:31 -04:00
var initSync sync.Once
2016-02-27 18:42:08 -05: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 10:59:31 -04:00
confPath, _ := filepath.Abs(filepath.Join(appPath, "tests", "sonic-test.toml"))
conf.LoadFromFile(confPath)
initSync.Do(func() {
beego.TestBeegoInit(appPath)
})
2016-02-27 18:42:08 -05:00
noLog := os.Getenv("NOLOG")
if noLog != "" {
beego.SetLevel(beego.LevelError)
}
2016-03-08 18:33:35 -05:00
utils.Graph.Finalize()
2016-02-27 18:42:08 -05:00
}