PreCache Playlists CoverArt
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
|
||||
"github.com/navidrome/navidrome/core"
|
||||
"github.com/navidrome/navidrome/core/artwork"
|
||||
|
||||
"github.com/navidrome/navidrome/conf"
|
||||
"github.com/navidrome/navidrome/consts"
|
||||
@@ -17,6 +18,7 @@ var _ = Describe("playlistImporter", func() {
|
||||
var ds model.DataStore
|
||||
var ps *playlistImporter
|
||||
var pls core.Playlists
|
||||
var cw artwork.CacheWarmer
|
||||
ctx := context.Background()
|
||||
|
||||
BeforeEach(func() {
|
||||
@@ -25,6 +27,8 @@ var _ = Describe("playlistImporter", func() {
|
||||
MockedPlaylist: &mockedPlaylist{},
|
||||
}
|
||||
pls = core.NewPlaylists(ds)
|
||||
|
||||
cw = &noopCacheWarmer{}
|
||||
})
|
||||
|
||||
Describe("processPlaylists", func() {
|
||||
@@ -33,19 +37,19 @@ var _ = Describe("playlistImporter", func() {
|
||||
conf.Server.PlaylistsPath = consts.DefaultPlaylistsPath
|
||||
})
|
||||
It("finds and import playlists at the top level", func() {
|
||||
ps = newPlaylistImporter(ds, pls, "tests/fixtures/playlists/subfolder1")
|
||||
ps = newPlaylistImporter(ds, pls, cw, "tests/fixtures/playlists/subfolder1")
|
||||
Expect(ps.processPlaylists(ctx, "tests/fixtures/playlists/subfolder1")).To(Equal(int64(1)))
|
||||
})
|
||||
|
||||
It("finds and import playlists at any subfolder level", func() {
|
||||
ps = newPlaylistImporter(ds, pls, "tests")
|
||||
ps = newPlaylistImporter(ds, pls, cw, "tests")
|
||||
Expect(ps.processPlaylists(ctx, "tests/fixtures/playlists/subfolder1")).To(Equal(int64(1)))
|
||||
})
|
||||
})
|
||||
|
||||
It("ignores playlists not in the PlaylistsPath", func() {
|
||||
conf.Server.PlaylistsPath = "subfolder1"
|
||||
ps = newPlaylistImporter(ds, pls, "tests/fixtures/playlists")
|
||||
ps = newPlaylistImporter(ds, pls, cw, "tests/fixtures/playlists")
|
||||
|
||||
Expect(ps.processPlaylists(ctx, "tests/fixtures/playlists/subfolder1")).To(Equal(int64(1)))
|
||||
Expect(ps.processPlaylists(ctx, "tests/fixtures/playlists/subfolder2")).To(Equal(int64(0)))
|
||||
@@ -53,7 +57,7 @@ var _ = Describe("playlistImporter", func() {
|
||||
|
||||
It("only imports playlists from the root of MusicFolder if PlaylistsPath is '.'", func() {
|
||||
conf.Server.PlaylistsPath = "."
|
||||
ps = newPlaylistImporter(ds, pls, "tests/fixtures/playlists")
|
||||
ps = newPlaylistImporter(ds, pls, cw, "tests/fixtures/playlists")
|
||||
|
||||
Expect(ps.processPlaylists(ctx, "tests/fixtures/playlists")).To(Equal(int64(3)))
|
||||
Expect(ps.processPlaylists(ctx, "tests/fixtures/playlists/subfolder1")).To(Equal(int64(0)))
|
||||
@@ -77,10 +81,14 @@ type mockedPlaylist struct {
|
||||
model.PlaylistRepository
|
||||
}
|
||||
|
||||
func (r *mockedPlaylist) FindByPath(path string) (*model.Playlist, error) {
|
||||
func (r *mockedPlaylist) FindByPath(_ string) (*model.Playlist, error) {
|
||||
return nil, model.ErrNotFound
|
||||
}
|
||||
|
||||
func (r *mockedPlaylist) Put(pls *model.Playlist) error {
|
||||
func (r *mockedPlaylist) Put(_ *model.Playlist) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
type noopCacheWarmer struct{}
|
||||
|
||||
func (a *noopCacheWarmer) PreCache(_ model.ArtworkID) {}
|
||||
|
||||
Reference in New Issue
Block a user