test(lyrics): fix lyrics tests after parser consolidation

- Rewrite the YAML-fallback test to assert the correct design: a
  non-Lyricsfile .yaml sidecar returns as plain text and shadows
  lower-priority sources (rather than falling through to .lrc).
- Add LibraryPath + relative Path split to the three subsonic tests
  that read sidecar files via storage.For(), so they resolve against
  the correct fixtures directory.
- Register a no-op extractor in api_suite_test.go BeforeSuite so
  newLocalStorage does not fatal when storage.For is called during
  sidecar-lyrics tests.
This commit is contained in:
Deluan 2026-06-19 15:04:03 -04:00
commit e797d69a58
4 changed files with 48 additions and 16 deletions

View file

@ -1,9 +1,13 @@
package subsonic
import (
"io/fs"
"testing"
"github.com/navidrome/navidrome/consts"
"github.com/navidrome/navidrome/core/storage/local"
"github.com/navidrome/navidrome/log"
"github.com/navidrome/navidrome/model/metadata"
"github.com/navidrome/navidrome/tests"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
@ -15,3 +19,16 @@ func TestSubsonicApi(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Subsonic API Suite")
}
// newLocalStorage fatals if the default extractor is not registered.
// Register a no-op so storage.For works in sidecar-lyrics tests.
var _ = BeforeSuite(func() {
local.RegisterExtractor(consts.DefaultScannerExtractor, func(fs.FS, string) local.Extractor {
return &subsonicNoopExtractor{}
})
})
type subsonicNoopExtractor struct{}
func (e *subsonicNoopExtractor) Parse(_ ...string) (map[string]metadata.Info, error) { return nil, nil }
func (e *subsonicNoopExtractor) Version() string { return "noop" }

View file

@ -2,6 +2,7 @@ package subsonic
import (
"encoding/json"
"path/filepath"
"github.com/navidrome/navidrome/conf"
"github.com/navidrome/navidrome/conf/configtest"
@ -202,13 +203,16 @@ var _ = Describe("GetLyricsBySongId", func() {
conf.Server.LyricsPriority = ".ttml,embedded"
r := newGetRequest("id=1")
fixturesDir, err := filepath.Abs("tests/fixtures")
Expect(err).ToNot(HaveOccurred())
mockRepo.SetData(model.MediaFiles{
{
ID: "1",
Path: "tests/fixtures/test.mp3",
Artist: "Rick Astley",
Title: "Never Gonna Give You Up",
Lyrics: "[]",
ID: "1",
LibraryPath: fixturesDir,
Path: "test.mp3",
Artist: "Rick Astley",
Title: "Never Gonna Give You Up",
Lyrics: "[]",
},
})
@ -255,13 +259,16 @@ var _ = Describe("GetLyricsBySongId", func() {
conf.Server.LyricsPriority = ".ttml,embedded"
r := newGetRequest("id=1&enhanced=true")
fixturesDir, err := filepath.Abs("tests/fixtures")
Expect(err).ToNot(HaveOccurred())
mockRepo.SetData(model.MediaFiles{
{
ID: "1",
Path: "tests/fixtures/test-metadata.mp3",
Artist: "Rick Astley",
Title: "Never Gonna Give You Up",
Lyrics: "[]",
ID: "1",
LibraryPath: fixturesDir,
Path: "test-metadata.mp3",
Artist: "Rick Astley",
Title: "Never Gonna Give You Up",
Lyrics: "[]",
},
})

View file

@ -8,6 +8,7 @@ import (
"errors"
"io"
"net/http/httptest"
"path/filepath"
"slices"
"time"
@ -164,12 +165,15 @@ var _ = Describe("MediaRetrievalController", func() {
})
It("should return lyric file when finding mediafile with no embedded lyrics but present on filesystem", func() {
r := newGetRequest("artist=Rick+Astley", "title=Never+Gonna+Give+You+Up")
fixturesDir, err := filepath.Abs("tests/fixtures")
Expect(err).ToNot(HaveOccurred())
mockRepo.SetData(model.MediaFiles{
{
Path: "tests/fixtures/test.mp3",
ID: "1",
Artist: "Rick Astley",
Title: "Never Gonna Give You Up",
LibraryPath: fixturesDir,
Path: "test.mp3",
ID: "1",
Artist: "Rick Astley",
Title: "Never Gonna Give You Up",
},
})
response, err := router.GetLyrics(r)