fix: persistence tests were not being properly initialized
This commit is contained in:
parent
7c2728aadc
commit
0ff741b394
|
@ -9,11 +9,13 @@ import (
|
||||||
"github.com/deluan/navidrome/conf"
|
"github.com/deluan/navidrome/conf"
|
||||||
"github.com/deluan/navidrome/log"
|
"github.com/deluan/navidrome/log"
|
||||||
"github.com/deluan/navidrome/model"
|
"github.com/deluan/navidrome/model"
|
||||||
|
"github.com/deluan/navidrome/tests"
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestPersistence(t *testing.T) {
|
func TestPersistence(t *testing.T) {
|
||||||
|
tests.Init(t, true)
|
||||||
log.SetLevel(log.LevelCritical)
|
log.SetLevel(log.LevelCritical)
|
||||||
RegisterFailHandler(Fail)
|
RegisterFailHandler(Fail)
|
||||||
RunSpecs(t, "Persistence Suite")
|
RunSpecs(t, "Persistence Suite")
|
||||||
|
@ -59,14 +61,14 @@ func P(path string) string {
|
||||||
|
|
||||||
var _ = Describe("Initialize test DB", func() {
|
var _ = Describe("Initialize test DB", func() {
|
||||||
BeforeSuite(func() {
|
BeforeSuite(func() {
|
||||||
//log.SetLevel(log.LevelTrace)
|
|
||||||
//conf.Server.DbPath, _ = ioutil.TempDir("", "navidrome_tests")
|
|
||||||
//os.MkdirAll(conf.Server.DbPath, 0700)
|
|
||||||
conf.Server.DbPath = ":memory:"
|
conf.Server.DbPath = ":memory:"
|
||||||
ds := New()
|
ds := New()
|
||||||
artistRepo := ds.Artist()
|
artistRepo := ds.Artist()
|
||||||
for _, a := range testArtists {
|
for _, a := range testArtists {
|
||||||
artistRepo.Put(&a)
|
err := artistRepo.Put(&a)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
albumRepository := ds.Album()
|
albumRepository := ds.Album()
|
||||||
for _, a := range testAlbums {
|
for _, a := range testAlbums {
|
||||||
|
|
|
@ -2,11 +2,8 @@ package scanner
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/deluan/navidrome/conf"
|
|
||||||
"github.com/deluan/navidrome/log"
|
"github.com/deluan/navidrome/log"
|
||||||
"github.com/deluan/navidrome/persistence"
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
)
|
)
|
||||||
|
@ -17,15 +14,3 @@ func xTestScanner(t *testing.T) {
|
||||||
RegisterFailHandler(Fail)
|
RegisterFailHandler(Fail)
|
||||||
RunSpecs(t, "Scanner Suite")
|
RunSpecs(t, "Scanner Suite")
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ = XDescribe("TODO: REMOVE", func() {
|
|
||||||
It("WORKS!", func() {
|
|
||||||
conf.Server.DbPath = "./testDB"
|
|
||||||
log.SetLevel(log.LevelDebug)
|
|
||||||
ds := persistence.New()
|
|
||||||
|
|
||||||
t := NewTagScanner("/Users/deluan/Music/iTunes/iTunes Media/Music", ds)
|
|
||||||
//t := NewTagScanner("/Users/deluan/Development/navidrome/navidrome/tests/fixtures", ds)
|
|
||||||
Expect(t.Scan(nil, time.Time{})).To(BeNil())
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
|
@ -4,25 +4,30 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/deluan/navidrome/conf"
|
"github.com/deluan/navidrome/conf"
|
||||||
"github.com/deluan/navidrome/log"
|
"github.com/deluan/navidrome/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var once sync.Once
|
||||||
|
|
||||||
func Init(t *testing.T, skipOnShort bool) {
|
func Init(t *testing.T, skipOnShort bool) {
|
||||||
if skipOnShort && testing.Short() {
|
if skipOnShort && testing.Short() {
|
||||||
t.Skip("skipping test in short mode.")
|
t.Skip("skipping test in short mode.")
|
||||||
}
|
}
|
||||||
_, file, _, _ := runtime.Caller(0)
|
once.Do(func() {
|
||||||
appPath, _ := filepath.Abs(filepath.Join(filepath.Dir(file), ".."))
|
_, file, _, _ := runtime.Caller(0)
|
||||||
confPath, _ := filepath.Abs(filepath.Join(appPath, "tests", "navidrome-test.toml"))
|
appPath, _ := filepath.Abs(filepath.Join(filepath.Dir(file), ".."))
|
||||||
|
confPath, _ := filepath.Abs(filepath.Join(appPath, "tests", "navidrome-test.toml"))
|
||||||
|
|
||||||
os.Chdir(appPath)
|
os.Chdir(appPath)
|
||||||
conf.LoadFromFile(confPath)
|
conf.LoadFromFile(confPath)
|
||||||
|
|
||||||
noLog := os.Getenv("NOLOG")
|
noLog := os.Getenv("NOLOG")
|
||||||
if noLog != "" {
|
if noLog != "" {
|
||||||
log.SetLevel(log.LevelError)
|
log.SetLevel(log.LevelError)
|
||||||
}
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue