mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-01 19:47:37 +03:00
* Set all clients to dev_download for make get-music * Use multiple TranscodingCache instances in tests This fixes flaky tests. The issue is that the TranscodingCache object was being reused in tests from media_stream_Internal_test.go and media_stream_test.go. If tests from the former was run first, the cache would be filled up, so that when running tests from the latter, the `NON seekable` test would fail. * Allow configuring cache folder This commit introduces a new configuration option to configure the cache folder. This allows the cache to be in a separate folder such as /var/cache/navidrome on Linux distributions. * Fix tests * Removed unused test setup code --------- Co-authored-by: Deluan <deluan@deluan.com> Co-authored-by: Deluan <deluan@navidrome.org>
33 lines
722 B
Go
33 lines
722 B
Go
package tests
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"runtime"
|
|
"sync"
|
|
"testing"
|
|
|
|
"github.com/navidrome/navidrome/conf"
|
|
"github.com/navidrome/navidrome/log"
|
|
)
|
|
|
|
var once sync.Once
|
|
|
|
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"))
|
|
println("Loading test configuration file from " + confPath)
|
|
_ = os.Chdir(appPath)
|
|
conf.LoadFromFile(confPath)
|
|
|
|
noLog := os.Getenv("NOLOG")
|
|
if noLog != "" {
|
|
log.SetLevel(log.LevelError)
|
|
}
|
|
})
|
|
}
|