mirror of
https://github.com/navidrome/navidrome.git
synced 2026-08-31 07:30:32 +00:00
test(subsonic): add Star/Unstar edge case tests
This commit is contained in:
parent
979c534bae
commit
166f08e470
@ -2,6 +2,7 @@ package subsonic
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
@ -131,6 +132,40 @@ var _ = Describe("MediaAnnotationController", func() {
|
||||
Expect(eventBroker.Events[0].Data(eventBroker.Events[0])).To(Equal(`{"song":["song-1"]}`))
|
||||
})
|
||||
|
||||
It("stars returns error when no id parameter is provided", func() {
|
||||
_, err := router.Star(newGetRequest())
|
||||
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(mediaRepo.SetStarCalls).To(BeEmpty())
|
||||
Expect(eventBroker.Events).To(BeEmpty())
|
||||
})
|
||||
|
||||
It("unstars returns error when no id parameter is provided", func() {
|
||||
_, err := router.Unstar(newGetRequest())
|
||||
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(mediaRepo.SetStarCalls).To(BeEmpty())
|
||||
Expect(eventBroker.Events).To(BeEmpty())
|
||||
})
|
||||
|
||||
It("returns error and calls repository when star persistence fails", func() {
|
||||
mediaRepo.Err = errors.New("db failure")
|
||||
_, err := router.Star(newGetRequest("id=song-1"))
|
||||
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(mediaRepo.SetStarCalls).To(HaveLen(1))
|
||||
Expect(eventBroker.Events).To(BeEmpty())
|
||||
})
|
||||
|
||||
It("returns error and calls repository when unstar persistence fails", func() {
|
||||
mediaRepo.Err = errors.New("db failure")
|
||||
_, err := router.Unstar(newGetRequest("id=song-1"))
|
||||
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(mediaRepo.SetStarCalls).To(HaveLen(1))
|
||||
Expect(eventBroker.Events).To(BeEmpty())
|
||||
})
|
||||
|
||||
It("rejects unauthenticated star requests before favoriting the song", func() {
|
||||
w := httptest.NewRecorder()
|
||||
r := httptest.NewRequest("GET", "/star?u=missing&v=1.16.1&c=test&id=song-1", nil)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user