quintodrome/tests/init_tests.go

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

34 lines
722 B
Go
Raw Normal View History

2016-02-27 14:42:08 -09:00
package tests
import (
"os"
"path/filepath"
"runtime"
"sync"
2016-02-27 14:42:08 -09:00
"testing"
2016-03-08 14:33:35 -09:00
2020-01-23 15:44:08 -09:00
"github.com/navidrome/navidrome/conf"
"github.com/navidrome/navidrome/log"
2016-02-27 14:42:08 -09:00
)
var once sync.Once
2016-02-27 14:42:08 -09:00
func Init(t *testing.T, 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.Abs(filepath.Join(appPath, "tests", "navidrome-test.toml"))
2020-01-26 14:07:06 -09:00
println("Loading test configuration file from " + confPath)
2020-04-26 08:35:26 -08:00
_ = os.Chdir(appPath)
conf.LoadFromFile(confPath)
2017-04-01 06:59:31 -08:00
noLog := os.Getenv("NOLOG")
if noLog != "" {
log.SetLevel(log.LevelError)
}
})
2016-02-27 14:42:08 -09:00
}