fix(subsonic): clearing playlist comment and public in Subsonic API (#4258)
* fix(subsonic): allow clearing playlist comment * fix(playlists): simplify comment and public parameter handling Signed-off-by: Deluan <deluan@navidrome.org> * refactor(playlists): streamline fakePlaylists implementation in tests Signed-off-by: Deluan <deluan@navidrome.org> --------- Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
@@ -219,4 +219,59 @@ var _ = Describe("Request Helpers", func() {
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Describe("ParamStringPtr", func() {
|
||||
BeforeEach(func() {
|
||||
r = req.Params(httptest.NewRequest("GET", "/ping?a=123", nil))
|
||||
})
|
||||
|
||||
It("returns pointer to string if param exists", func() {
|
||||
ptr := r.StringPtr("a")
|
||||
Expect(ptr).ToNot(BeNil())
|
||||
Expect(*ptr).To(Equal("123"))
|
||||
})
|
||||
|
||||
It("returns nil if param does not exist", func() {
|
||||
ptr := r.StringPtr("xx")
|
||||
Expect(ptr).To(BeNil())
|
||||
})
|
||||
|
||||
It("returns pointer to empty string if param exists but is empty", func() {
|
||||
r = req.Params(httptest.NewRequest("GET", "/ping?a=", nil))
|
||||
ptr := r.StringPtr("a")
|
||||
Expect(ptr).ToNot(BeNil())
|
||||
Expect(*ptr).To(Equal(""))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("ParamBoolPtr", func() {
|
||||
Context("value is true", func() {
|
||||
BeforeEach(func() {
|
||||
r = req.Params(httptest.NewRequest("GET", "/ping?b=true", nil))
|
||||
})
|
||||
|
||||
It("returns pointer to true if param is 'true'", func() {
|
||||
ptr := r.BoolPtr("b")
|
||||
Expect(ptr).ToNot(BeNil())
|
||||
Expect(*ptr).To(BeTrue())
|
||||
})
|
||||
})
|
||||
|
||||
Context("value is false", func() {
|
||||
BeforeEach(func() {
|
||||
r = req.Params(httptest.NewRequest("GET", "/ping?b=false", nil))
|
||||
})
|
||||
|
||||
It("returns pointer to false if param is 'false'", func() {
|
||||
ptr := r.BoolPtr("b")
|
||||
Expect(ptr).ToNot(BeNil())
|
||||
Expect(*ptr).To(BeFalse())
|
||||
})
|
||||
})
|
||||
|
||||
It("returns nil if param does not exist", func() {
|
||||
ptr := r.BoolPtr("xx")
|
||||
Expect(ptr).To(BeNil())
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user