navidrome/model/artist_test.go
Deluan e100c48102 fix(artwork): address blurhash review findings
- force recompute on image-cache miss, so in-place cover/sidecar swaps and
  agent image updates refresh the stored hash even when no entity row moved
- exclude external_info_updated_at from the artwork version: agent TTL
  refreshes bump it with an unchanged image, churning Finamp's cover cache
- lazy-start the worker goroutine and bound each computation with a 30s
  timeout; remember no-result entities per version to avoid re-decoding
  placeholders on every serve
- error (instead of silently skipping) on unknown artwork kinds in persist
2026-07-16 21:52:28 -04:00

46 lines
1.4 KiB
Go

package model_test
import (
"path/filepath"
"time"
"github.com/navidrome/navidrome/conf"
"github.com/navidrome/navidrome/conf/configtest"
"github.com/navidrome/navidrome/model"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
var _ = Describe("Artist", func() {
Describe("UploadedImagePath", func() {
BeforeEach(func() {
DeferCleanup(configtest.SetupConfig())
conf.Server.DataFolder = conf.NewDir("/data")
})
It("returns empty string when no image uploaded", func() {
a := model.Artist{ID: "ar-1"}
Expect(a.UploadedImagePath()).To(BeEmpty())
})
It("returns full path when image is set", func() {
a := model.Artist{ID: "ar-1", UploadedImage: "ar-1_test.jpg"}
Expect(a.UploadedImagePath()).To(Equal(filepath.Join("/data", "artwork", "artist", "ar-1_test.jpg")))
})
})
})
var _ = Describe("Artist.ArtworkUpdatedAt", func() {
base := time.Date(2024, 1, 1, 0, 0, 0, 0, time.UTC)
later := base.Add(24 * time.Hour)
It("handles nil timestamps", func() {
Expect(model.Artist{}.ArtworkUpdatedAt()).To(Equal(time.Time{}))
})
It("returns UpdatedAt", func() {
Expect(model.Artist{UpdatedAt: &later, ExternalInfoUpdatedAt: &base}.ArtworkUpdatedAt()).To(Equal(later))
})
It("ignores ExternalInfoUpdatedAt (agent TTL refreshes bump it without an image change)", func() {
Expect(model.Artist{UpdatedAt: &base, ExternalInfoUpdatedAt: &later}.ArtworkUpdatedAt()).To(Equal(base))
})
})