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:
Deluan Quintão 2026-04-26 17:34:39 -04:00 committed by GitHub
parent fd930eefd7
commit a756cad1dc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 17 deletions

View File

@ -41,6 +41,7 @@ var _ = Describe("Artwork", func() {
MockedTranscoding: &tests.MockTranscodingRepo{},
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"}}
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: ""}}
@ -80,12 +81,11 @@ var _ = Describe("Artwork", func() {
})
})
It("returns embed cover", func() {
tests.SkipOnWindows("artwork path handling (#TBD-path-sep-artwork)")
aw, err := newAlbumArtworkReader(ctx, aw, alOnlyEmbed.CoverArtID(), nil)
Expect(err).ToNot(HaveOccurred())
_, path, err := aw.Reader(ctx)
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() {
ffmpeg.Error = errors.New("not available")
@ -104,7 +104,6 @@ var _ = Describe("Artwork", func() {
})
})
It("returns external cover", func() {
tests.SkipOnWindows("artwork path handling (#TBD-path-sep-artwork)")
folderRepo.result = []model.Folder{{
Path: "tests/fixtures/artist/an-album",
ImageFiles: []string{"front.png"},
@ -113,7 +112,7 @@ var _ = Describe("Artwork", func() {
Expect(err).ToNot(HaveOccurred())
_, path, err := aw.Reader(ctx)
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() {
folderRepo.result = []model.Folder{}
@ -135,13 +134,12 @@ var _ = Describe("Artwork", func() {
})
DescribeTable("CoverArtPriority",
func(priority string, expected string) {
tests.SkipOnWindows("artwork path handling (#TBD-path-sep-artwork)")
conf.Server.CoverArtPriority = priority
aw, err := newAlbumArtworkReader(ctx, aw, alMultipleCovers.CoverArtID(), nil)
Expect(err).ToNot(HaveOccurred())
_, path, err := aw.Reader(ctx)
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, "front.* , cover.*, embedded ,folder.*", "tests/fixtures/artist/an-album/front.png"),
@ -213,13 +211,12 @@ var _ = Describe("Artwork", func() {
})
DescribeTable("ArtistArtPriority",
func(priority string, expected string) {
tests.SkipOnWindows("artwork path handling (#TBD-path-sep-artwork)")
conf.Server.ArtistArtPriority = priority
aw, err := newArtistArtworkReader(ctx, aw, arMultipleCovers.CoverArtID(), nil)
Expect(err).ToNot(HaveOccurred())
_, path, err := aw.Reader(ctx)
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, "album/artist.*, folder.*,artist.*", "tests/fixtures/artist/an-album/artist.png"),
@ -251,22 +248,20 @@ var _ = Describe("Artwork", func() {
})
})
It("returns embed cover", func() {
tests.SkipOnWindows("artwork path handling (#TBD-path-sep-artwork)")
aw, err := newMediafileArtworkReader(ctx, aw, mfWithEmbed.CoverArtID())
Expect(err).ToNot(HaveOccurred())
_, path, err := aw.Reader(ctx)
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() {
tests.SkipOnWindows("artwork path handling (#TBD-path-sep-artwork)")
aw, err := newMediafileArtworkReader(ctx, aw, mfCorruptedCover.CoverArtID())
Expect(err).ToNot(HaveOccurred())
r, path, err := aw.Reader(ctx)
Expect(err).ToNot(HaveOccurred())
data, _ := io.ReadAll(r)
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() {
// Force fromTag to fail

View File

@ -12,7 +12,6 @@ import (
"github.com/navidrome/navidrome/conf/configtest"
"github.com/navidrome/navidrome/core"
"github.com/navidrome/navidrome/model"
"github.com/navidrome/navidrome/tests"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
@ -62,13 +61,12 @@ var _ = Describe("artistArtworkReader", func() {
When("artist has only one album", func() {
It("returns the parent folder", func() {
tests.SkipOnWindows("artwork path handling (#TBD-path-sep-artwork)")
paths = []string{
filepath.FromSlash("/music/artist/album1"),
}
folder, upd, err := loadArtistFolder(ctx, fds, albums, paths)
Expect(err).ToNot(HaveOccurred())
Expect(folder).To(Equal("/music/artist"))
Expect(folder).To(Equal(filepath.FromSlash("/music/artist")))
Expect(upd).To(Equal(expectedUpdTime))
})
})
@ -88,14 +86,13 @@ var _ = Describe("artistArtworkReader", func() {
When("the album paths contain same prefix", func() {
It("returns the common prefix", func() {
tests.SkipOnWindows("artwork path handling (#TBD-path-sep-artwork)")
paths = []string{
filepath.FromSlash("/music/artist/album1"),
filepath.FromSlash("/music/artist/album2"),
}
folder, upd, err := loadArtistFolder(ctx, fds, albums, paths)
Expect(err).ToNot(HaveOccurred())
Expect(folder).To(Equal("/music/artist"))
Expect(folder).To(Equal(filepath.FromSlash("/music/artist")))
Expect(upd).To(Equal(expectedUpdTime))
})
})