mirror of
https://github.com/navidrome/navidrome.git
synced 2026-11-18 02:52:36 +03:00
38 lines
846 B
Go
38 lines
846 B
Go
package tests
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"runtime"
|
|
"sync"
|
|
"testing"
|
|
|
|
"github.com/navidrome/navidrome/conf"
|
|
_ "github.com/navidrome/navidrome/conf/mime" // registers mime_types.yaml, so tests see the same image types as the server
|
|
"github.com/navidrome/navidrome/log"
|
|
)
|
|
|
|
var (
|
|
once sync.Once
|
|
appPath string
|
|
)
|
|
|
|
func Init(t testing.TB, skipOnShort bool) {
|
|
if skipOnShort && testing.Short() {
|
|
t.Skip("skipping test in short mode.")
|
|
}
|
|
once.Do(func() {
|
|
_, file, _, _ := runtime.Caller(0)
|
|
appPath, _ = filepath.Abs(filepath.Join(filepath.Dir(file), ".."))
|
|
confPath := filepath.Join(appPath, "tests", "navidrome-test.toml")
|
|
println("Loading test configuration file from " + confPath)
|
|
conf.LoadFromFile(confPath)
|
|
|
|
noLog := os.Getenv("NOLOG")
|
|
if noLog != "" {
|
|
log.SetLevel(log.LevelError)
|
|
}
|
|
})
|
|
t.Chdir(appPath)
|
|
}
|