navidrome/tests/init_tests.go

28 lines
602 B
Go
Raw Normal View History

2016-02-27 18:42:08 -05:00
package tests
import (
"os"
"path/filepath"
"runtime"
"testing"
2016-03-08 18:33:35 -05:00
2017-04-01 09:47:14 -04:00
"github.com/cloudsonic/sonic-server/conf"
2020-01-08 20:45:07 -05:00
"github.com/cloudsonic/sonic-server/log"
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"))
2020-01-08 20:45:07 -05:00
os.Chdir(appPath)
2017-04-01 10:59:31 -04:00
conf.LoadFromFile(confPath)
2016-02-27 18:42:08 -05:00
noLog := os.Getenv("NOLOG")
if noLog != "" {
2020-01-08 20:45:07 -05:00
log.SetLevel(log.LevelError)
2016-02-27 18:42:08 -05:00
}
}