Return 404 when artwork is not available in /share/img endpoint

This commit is contained in:
Deluan
2023-01-31 18:22:49 -05:00
committed by Deluan Quintão
parent 128b626ec9
commit d8e794317f
13 changed files with 75 additions and 90 deletions
+21 -11
View File
@@ -28,20 +28,30 @@ var _ = Describe("Artwork", func() {
aw = artwork.NewArtwork(ds, cache, ffmpeg, nil)
})
Context("Empty ID", func() {
It("returns placeholder if album is not in the DB", func() {
r, _, err := aw.Get(context.Background(), "", 0)
Expect(err).ToNot(HaveOccurred())
Context("GetOrPlaceholder", func() {
Context("Empty ID", func() {
It("returns placeholder if album is not in the DB", func() {
r, _, err := aw.GetOrPlaceholder(context.Background(), "", 0)
Expect(err).ToNot(HaveOccurred())
ph, err := resources.FS().Open(consts.PlaceholderAlbumArt)
Expect(err).ToNot(HaveOccurred())
phBytes, err := io.ReadAll(ph)
Expect(err).ToNot(HaveOccurred())
ph, err := resources.FS().Open(consts.PlaceholderAlbumArt)
Expect(err).ToNot(HaveOccurred())
phBytes, err := io.ReadAll(ph)
Expect(err).ToNot(HaveOccurred())
result, err := io.ReadAll(r)
Expect(err).ToNot(HaveOccurred())
result, err := io.ReadAll(r)
Expect(err).ToNot(HaveOccurred())
Expect(result).To(Equal(phBytes))
Expect(result).To(Equal(phBytes))
})
})
})
Context("Get", func() {
Context("Empty ID", func() {
It("returns an ErrUnavailable error", func() {
_, _, err := aw.Get(context.Background(), model.ArtworkID{}, 0)
Expect(err).To(MatchError(artwork.ErrUnavailable))
})
})
})
})