2016-02-28 00:42:08 +01:00
|
|
|
package tests
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
"runtime"
|
2020-01-26 23:10:13 +01:00
|
|
|
"sync"
|
2016-02-28 00:42:08 +01:00
|
|
|
"testing"
|
2016-03-09 00:33:35 +01:00
|
|
|
|
2020-01-24 01:44:08 +01:00
|
|
|
"github.com/deluan/navidrome/conf"
|
|
|
|
"github.com/deluan/navidrome/log"
|
2016-02-28 00:42:08 +01:00
|
|
|
)
|
|
|
|
|
2020-01-26 23:10:13 +01:00
|
|
|
var once sync.Once
|
|
|
|
|
2016-02-28 00:42:08 +01:00
|
|
|
func Init(t *testing.T, skipOnShort bool) {
|
|
|
|
if skipOnShort && testing.Short() {
|
|
|
|
t.Skip("skipping test in short mode.")
|
|
|
|
}
|
2020-01-26 23:10:13 +01:00
|
|
|
once.Do(func() {
|
|
|
|
_, file, _, _ := runtime.Caller(0)
|
|
|
|
appPath, _ := filepath.Abs(filepath.Join(filepath.Dir(file), ".."))
|
|
|
|
confPath, _ := filepath.Abs(filepath.Join(appPath, "tests", "navidrome-test.toml"))
|
2020-01-27 00:07:06 +01:00
|
|
|
println("Loading test configuration file from " + confPath)
|
2020-04-26 18:35:26 +02:00
|
|
|
_ = os.Chdir(appPath)
|
2020-01-27 00:07:06 +01:00
|
|
|
conf.LoadFromFile("tests/navidrome-test.toml", true)
|
2017-04-01 16:59:31 +02:00
|
|
|
|
2020-01-26 23:10:13 +01:00
|
|
|
noLog := os.Getenv("NOLOG")
|
|
|
|
if noLog != "" {
|
|
|
|
log.SetLevel(log.LevelError)
|
|
|
|
}
|
|
|
|
})
|
2016-02-28 00:42:08 +01:00
|
|
|
}
|