mirror of
https://github.com/navidrome/navidrome.git
synced 2026-07-30 16:56:22 -04:00
Like Subsonic's setStar/setRating, the Jellyfin favorite and rating endpoints now broadcast a refreshResource event, so the web UI updates immediately when a Jellyfin client changes an annotation. Also fixes model.GetEntityByID to propagate unexpected repository errors instead of reporting them as not-found, preserving the 500-vs-404 distinction for all its callers.
41 lines
1.1 KiB
Go
41 lines
1.1 KiB
Go
package model_test
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/navidrome/navidrome/model"
|
|
"github.com/navidrome/navidrome/tests"
|
|
. "github.com/onsi/ginkgo/v2"
|
|
. "github.com/onsi/gomega"
|
|
)
|
|
|
|
var _ = Describe("GetEntityByID", func() {
|
|
var ds *tests.MockDataStore
|
|
var ctx context.Context
|
|
|
|
BeforeEach(func() {
|
|
ds = &tests.MockDataStore{}
|
|
ctx = GinkgoT().Context()
|
|
})
|
|
|
|
It("returns the entity matching the id", func() {
|
|
ds.Album(ctx).(*tests.MockAlbumRepo).SetData(model.Albums{{ID: "a1", Name: "One"}})
|
|
entity, err := model.GetEntityByID(ctx, ds, "a1")
|
|
Expect(err).ToNot(HaveOccurred())
|
|
Expect(entity).To(BeAssignableToTypeOf(&model.Album{}))
|
|
Expect(entity.(*model.Album).ID).To(Equal("a1"))
|
|
})
|
|
|
|
It("returns ErrNotFound when no entity matches", func() {
|
|
_, err := model.GetEntityByID(ctx, ds, "missing")
|
|
Expect(err).To(MatchError(model.ErrNotFound))
|
|
})
|
|
|
|
It("propagates unexpected repository errors instead of reporting not-found", func() {
|
|
ds.Album(ctx).(*tests.MockAlbumRepo).SetError(true)
|
|
_, err := model.GetEntityByID(ctx, ds, "a1")
|
|
Expect(err).To(HaveOccurred())
|
|
Expect(err).ToNot(MatchError(model.ErrNotFound))
|
|
})
|
|
})
|