mirror of
https://github.com/navidrome/navidrome.git
synced 2026-05-03 06:51:16 +00:00
test: enable artwork tests on Windows (#5416)
* fix(test): enable artwork tests on Windows by using OS-aware path assertions
Replace hardcoded forward-slash path expectations with filepath.FromSlash()
so assertions match OS-native separators on Windows. Removes all 8
SkipOnWindows("#TBD-path-sep-artwork") guards from artwork unit tests.
* test: add comment explaining forward-slash paths in test fixtures
This commit is contained in:
parent
fd930eefd7
commit
a756cad1dc
@ -41,6 +41,7 @@ var _ = Describe("Artwork", func() {
|
|||||||
MockedTranscoding: &tests.MockTranscodingRepo{},
|
MockedTranscoding: &tests.MockTranscodingRepo{},
|
||||||
MockedFolder: folderRepo,
|
MockedFolder: folderRepo,
|
||||||
}
|
}
|
||||||
|
// Paths use forward slashes because the scanner stores fs.FS-relative paths in the DB.
|
||||||
alOnlyEmbed = model.Album{ID: "222", Name: "Only embed", EmbedArtPath: "tests/fixtures/artist/an-album/test.mp3", FolderIDs: []string{"f1"}}
|
alOnlyEmbed = model.Album{ID: "222", Name: "Only embed", EmbedArtPath: "tests/fixtures/artist/an-album/test.mp3", FolderIDs: []string{"f1"}}
|
||||||
alEmbedNotFound = model.Album{ID: "333", Name: "Embed not found", EmbedArtPath: "tests/fixtures/NON_EXISTENT.mp3", FolderIDs: []string{"f1"}}
|
alEmbedNotFound = model.Album{ID: "333", Name: "Embed not found", EmbedArtPath: "tests/fixtures/NON_EXISTENT.mp3", FolderIDs: []string{"f1"}}
|
||||||
alOnlyExternal = model.Album{ID: "444", Name: "Only external", FolderIDs: []string{"f1"}, Discs: model.Discs{1: "", 2: ""}}
|
alOnlyExternal = model.Album{ID: "444", Name: "Only external", FolderIDs: []string{"f1"}, Discs: model.Discs{1: "", 2: ""}}
|
||||||
@ -80,12 +81,11 @@ var _ = Describe("Artwork", func() {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
It("returns embed cover", func() {
|
It("returns embed cover", func() {
|
||||||
tests.SkipOnWindows("artwork path handling (#TBD-path-sep-artwork)")
|
|
||||||
aw, err := newAlbumArtworkReader(ctx, aw, alOnlyEmbed.CoverArtID(), nil)
|
aw, err := newAlbumArtworkReader(ctx, aw, alOnlyEmbed.CoverArtID(), nil)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
_, path, err := aw.Reader(ctx)
|
_, path, err := aw.Reader(ctx)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(path).To(Equal("tests/fixtures/artist/an-album/test.mp3"))
|
Expect(path).To(Equal(filepath.FromSlash("tests/fixtures/artist/an-album/test.mp3")))
|
||||||
})
|
})
|
||||||
It("returns ErrUnavailable if embed path is not available", func() {
|
It("returns ErrUnavailable if embed path is not available", func() {
|
||||||
ffmpeg.Error = errors.New("not available")
|
ffmpeg.Error = errors.New("not available")
|
||||||
@ -104,7 +104,6 @@ var _ = Describe("Artwork", func() {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
It("returns external cover", func() {
|
It("returns external cover", func() {
|
||||||
tests.SkipOnWindows("artwork path handling (#TBD-path-sep-artwork)")
|
|
||||||
folderRepo.result = []model.Folder{{
|
folderRepo.result = []model.Folder{{
|
||||||
Path: "tests/fixtures/artist/an-album",
|
Path: "tests/fixtures/artist/an-album",
|
||||||
ImageFiles: []string{"front.png"},
|
ImageFiles: []string{"front.png"},
|
||||||
@ -113,7 +112,7 @@ var _ = Describe("Artwork", func() {
|
|||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
_, path, err := aw.Reader(ctx)
|
_, path, err := aw.Reader(ctx)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(path).To(Equal("tests/fixtures/artist/an-album/front.png"))
|
Expect(path).To(Equal(filepath.FromSlash("tests/fixtures/artist/an-album/front.png")))
|
||||||
})
|
})
|
||||||
It("returns ErrUnavailable if external file is not available", func() {
|
It("returns ErrUnavailable if external file is not available", func() {
|
||||||
folderRepo.result = []model.Folder{}
|
folderRepo.result = []model.Folder{}
|
||||||
@ -135,13 +134,12 @@ var _ = Describe("Artwork", func() {
|
|||||||
})
|
})
|
||||||
DescribeTable("CoverArtPriority",
|
DescribeTable("CoverArtPriority",
|
||||||
func(priority string, expected string) {
|
func(priority string, expected string) {
|
||||||
tests.SkipOnWindows("artwork path handling (#TBD-path-sep-artwork)")
|
|
||||||
conf.Server.CoverArtPriority = priority
|
conf.Server.CoverArtPriority = priority
|
||||||
aw, err := newAlbumArtworkReader(ctx, aw, alMultipleCovers.CoverArtID(), nil)
|
aw, err := newAlbumArtworkReader(ctx, aw, alMultipleCovers.CoverArtID(), nil)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
_, path, err := aw.Reader(ctx)
|
_, path, err := aw.Reader(ctx)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(path).To(Equal(expected))
|
Expect(path).To(Equal(filepath.FromSlash(expected)))
|
||||||
},
|
},
|
||||||
Entry(nil, " folder.* , cover.*,embedded,front.*", "tests/fixtures/artist/an-album/cover.jpg"),
|
Entry(nil, " folder.* , cover.*,embedded,front.*", "tests/fixtures/artist/an-album/cover.jpg"),
|
||||||
Entry(nil, "front.* , cover.*, embedded ,folder.*", "tests/fixtures/artist/an-album/front.png"),
|
Entry(nil, "front.* , cover.*, embedded ,folder.*", "tests/fixtures/artist/an-album/front.png"),
|
||||||
@ -213,13 +211,12 @@ var _ = Describe("Artwork", func() {
|
|||||||
})
|
})
|
||||||
DescribeTable("ArtistArtPriority",
|
DescribeTable("ArtistArtPriority",
|
||||||
func(priority string, expected string) {
|
func(priority string, expected string) {
|
||||||
tests.SkipOnWindows("artwork path handling (#TBD-path-sep-artwork)")
|
|
||||||
conf.Server.ArtistArtPriority = priority
|
conf.Server.ArtistArtPriority = priority
|
||||||
aw, err := newArtistArtworkReader(ctx, aw, arMultipleCovers.CoverArtID(), nil)
|
aw, err := newArtistArtworkReader(ctx, aw, arMultipleCovers.CoverArtID(), nil)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
_, path, err := aw.Reader(ctx)
|
_, path, err := aw.Reader(ctx)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(path).To(Equal(expected))
|
Expect(path).To(Equal(filepath.FromSlash(expected)))
|
||||||
},
|
},
|
||||||
Entry(nil, " folder.* , artist.*,album/artist.*", "tests/fixtures/artist/artist.jpg"),
|
Entry(nil, " folder.* , artist.*,album/artist.*", "tests/fixtures/artist/artist.jpg"),
|
||||||
Entry(nil, "album/artist.*, folder.*,artist.*", "tests/fixtures/artist/an-album/artist.png"),
|
Entry(nil, "album/artist.*, folder.*,artist.*", "tests/fixtures/artist/an-album/artist.png"),
|
||||||
@ -251,22 +248,20 @@ var _ = Describe("Artwork", func() {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
It("returns embed cover", func() {
|
It("returns embed cover", func() {
|
||||||
tests.SkipOnWindows("artwork path handling (#TBD-path-sep-artwork)")
|
|
||||||
aw, err := newMediafileArtworkReader(ctx, aw, mfWithEmbed.CoverArtID())
|
aw, err := newMediafileArtworkReader(ctx, aw, mfWithEmbed.CoverArtID())
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
_, path, err := aw.Reader(ctx)
|
_, path, err := aw.Reader(ctx)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(path).To(Equal("tests/fixtures/test.mp3"))
|
Expect(path).To(Equal(filepath.FromSlash("tests/fixtures/test.mp3")))
|
||||||
})
|
})
|
||||||
It("returns embed cover if successfully extracted by ffmpeg", func() {
|
It("returns embed cover if successfully extracted by ffmpeg", func() {
|
||||||
tests.SkipOnWindows("artwork path handling (#TBD-path-sep-artwork)")
|
|
||||||
aw, err := newMediafileArtworkReader(ctx, aw, mfCorruptedCover.CoverArtID())
|
aw, err := newMediafileArtworkReader(ctx, aw, mfCorruptedCover.CoverArtID())
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
r, path, err := aw.Reader(ctx)
|
r, path, err := aw.Reader(ctx)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
data, _ := io.ReadAll(r)
|
data, _ := io.ReadAll(r)
|
||||||
Expect(data).ToNot(BeEmpty())
|
Expect(data).ToNot(BeEmpty())
|
||||||
Expect(path).To(Equal("tests/fixtures/test.ogg"))
|
Expect(path).To(Equal(filepath.FromSlash("tests/fixtures/test.ogg")))
|
||||||
})
|
})
|
||||||
It("returns album cover if cannot read embed artwork", func() {
|
It("returns album cover if cannot read embed artwork", func() {
|
||||||
// Force fromTag to fail
|
// Force fromTag to fail
|
||||||
|
|||||||
@ -12,7 +12,6 @@ import (
|
|||||||
"github.com/navidrome/navidrome/conf/configtest"
|
"github.com/navidrome/navidrome/conf/configtest"
|
||||||
"github.com/navidrome/navidrome/core"
|
"github.com/navidrome/navidrome/core"
|
||||||
"github.com/navidrome/navidrome/model"
|
"github.com/navidrome/navidrome/model"
|
||||||
"github.com/navidrome/navidrome/tests"
|
|
||||||
. "github.com/onsi/ginkgo/v2"
|
. "github.com/onsi/ginkgo/v2"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
)
|
)
|
||||||
@ -62,13 +61,12 @@ var _ = Describe("artistArtworkReader", func() {
|
|||||||
|
|
||||||
When("artist has only one album", func() {
|
When("artist has only one album", func() {
|
||||||
It("returns the parent folder", func() {
|
It("returns the parent folder", func() {
|
||||||
tests.SkipOnWindows("artwork path handling (#TBD-path-sep-artwork)")
|
|
||||||
paths = []string{
|
paths = []string{
|
||||||
filepath.FromSlash("/music/artist/album1"),
|
filepath.FromSlash("/music/artist/album1"),
|
||||||
}
|
}
|
||||||
folder, upd, err := loadArtistFolder(ctx, fds, albums, paths)
|
folder, upd, err := loadArtistFolder(ctx, fds, albums, paths)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(folder).To(Equal("/music/artist"))
|
Expect(folder).To(Equal(filepath.FromSlash("/music/artist")))
|
||||||
Expect(upd).To(Equal(expectedUpdTime))
|
Expect(upd).To(Equal(expectedUpdTime))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -88,14 +86,13 @@ var _ = Describe("artistArtworkReader", func() {
|
|||||||
|
|
||||||
When("the album paths contain same prefix", func() {
|
When("the album paths contain same prefix", func() {
|
||||||
It("returns the common prefix", func() {
|
It("returns the common prefix", func() {
|
||||||
tests.SkipOnWindows("artwork path handling (#TBD-path-sep-artwork)")
|
|
||||||
paths = []string{
|
paths = []string{
|
||||||
filepath.FromSlash("/music/artist/album1"),
|
filepath.FromSlash("/music/artist/album1"),
|
||||||
filepath.FromSlash("/music/artist/album2"),
|
filepath.FromSlash("/music/artist/album2"),
|
||||||
}
|
}
|
||||||
folder, upd, err := loadArtistFolder(ctx, fds, albums, paths)
|
folder, upd, err := loadArtistFolder(ctx, fds, albums, paths)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(folder).To(Equal("/music/artist"))
|
Expect(folder).To(Equal(filepath.FromSlash("/music/artist")))
|
||||||
Expect(upd).To(Equal(expectedUpdTime))
|
Expect(upd).To(Equal(expectedUpdTime))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user