Add discTitles to OpenSubsonic responses
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
package subsonic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/navidrome/navidrome/model"
|
||||
"github.com/navidrome/navidrome/server/subsonic/responses"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
@@ -33,4 +36,38 @@ var _ = Describe("helpers", func() {
|
||||
Expect(mapSlashToDash("AC/DC")).To(Equal("AC_DC"))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("buildDiscTitles", func() {
|
||||
It("should return nil when album has no discs", func() {
|
||||
album := model.Album{}
|
||||
Expect(buildDiscSubtitles(context.Background(), album)).To(BeNil())
|
||||
})
|
||||
|
||||
It("should return correct disc titles when album has discs with valid disc numbers", func() {
|
||||
album := model.Album{
|
||||
Discs: map[string]string{
|
||||
"1": "Disc 1",
|
||||
"2": "Disc 2",
|
||||
},
|
||||
}
|
||||
expected := responses.DiscTitles{
|
||||
{Disc: 1, Title: "Disc 1"},
|
||||
{Disc: 2, Title: "Disc 2"},
|
||||
}
|
||||
Expect(buildDiscSubtitles(context.Background(), album)).To(Equal(expected))
|
||||
})
|
||||
|
||||
It("should skip discs with invalid disc numbers", func() {
|
||||
album := model.Album{
|
||||
Discs: map[string]string{
|
||||
"1": "Disc 1",
|
||||
"two": "Disc 2",
|
||||
},
|
||||
}
|
||||
expected := responses.DiscTitles{
|
||||
{Disc: 1, Title: "Disc 1"},
|
||||
}
|
||||
Expect(buildDiscSubtitles(context.Background(), album)).To(Equal(expected))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user