fix: persistence tests were not being properly initialized
This commit is contained in:
+14
-9
@@ -4,25 +4,30 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"github.com/deluan/navidrome/conf"
|
||||
"github.com/deluan/navidrome/log"
|
||||
)
|
||||
|
||||
var once sync.Once
|
||||
|
||||
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), ".."))
|
||||
confPath, _ := filepath.Abs(filepath.Join(appPath, "tests", "navidrome-test.toml"))
|
||||
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"))
|
||||
|
||||
os.Chdir(appPath)
|
||||
conf.LoadFromFile(confPath)
|
||||
os.Chdir(appPath)
|
||||
conf.LoadFromFile(confPath)
|
||||
|
||||
noLog := os.Getenv("NOLOG")
|
||||
if noLog != "" {
|
||||
log.SetLevel(log.LevelError)
|
||||
}
|
||||
noLog := os.Getenv("NOLOG")
|
||||
if noLog != "" {
|
||||
log.SetLevel(log.LevelError)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user