diff --git a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses PlayQueue with data should match .JSON b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses PlayQueue with data should match .JSON new file mode 100644 index 00000000000..3821ebd68b4 --- /dev/null +++ b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses PlayQueue with data should match .JSON @@ -0,0 +1 @@ +{"status":"ok","version":"1.8.0","type":"navidrome","serverVersion":"v0.0.0","playQueue":{"entry":[{"id":"1","isDir":false,"title":"title","isVideo":false}],"current":"111","position":243,"username":"user1","changed":"0001-01-01T00:00:00Z","changedBy":"a_client"}} diff --git a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses PlayQueue with data should match .XML b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses PlayQueue with data should match .XML new file mode 100644 index 00000000000..9e0f82aef5f --- /dev/null +++ b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses PlayQueue with data should match .XML @@ -0,0 +1 @@ + diff --git a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses PlayQueue without data should match .JSON b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses PlayQueue without data should match .JSON new file mode 100644 index 00000000000..0386aaa90b0 --- /dev/null +++ b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses PlayQueue without data should match .JSON @@ -0,0 +1 @@ +{"status":"ok","version":"1.8.0","type":"navidrome","serverVersion":"v0.0.0","playQueue":{"username":"","changedBy":""}} diff --git a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses PlayQueue without data should match .XML b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses PlayQueue without data should match .XML new file mode 100644 index 00000000000..42ccb087fe5 --- /dev/null +++ b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses PlayQueue without data should match .XML @@ -0,0 +1 @@ + diff --git a/server/subsonic/responses/responses.go b/server/subsonic/responses/responses.go index a44ea61ee2b..eb529ea145c 100644 --- a/server/subsonic/responses/responses.go +++ b/server/subsonic/responses/responses.go @@ -36,8 +36,10 @@ type Subsonic struct { ArtistWithAlbumsID3 *ArtistWithAlbumsID3 `xml:"artist,omitempty" json:"artist,omitempty"` AlbumWithSongsID3 *AlbumWithSongsID3 `xml:"album,omitempty" json:"album,omitempty"` - ArtistInfo *ArtistInfo `xml:"artistInfo,omitempty" json:"artistInfo,omitempty"` - ArtistInfo2 *ArtistInfo2 `xml:"artistInfo2,omitempty" json:"artistInfo2,omitempty"` + ArtistInfo *ArtistInfo `xml:"artistInfo,omitempty" json:"artistInfo,omitempty"` + ArtistInfo2 *ArtistInfo2 `xml:"artistInfo2,omitempty" json:"artistInfo2,omitempty"` + + PlayQueue *PlayQueue `xml:"playQueue,omitempty" json:"playQueue,omitempty"` } type JsonWrapper struct { @@ -293,3 +295,12 @@ type ArtistInfo2 struct { ArtistInfoBase SimilarArtist []ArtistID3 `xml:"similarArtist,omitempty" json:"similarArtist,omitempty"` } + +type PlayQueue struct { + Entry []Child `xml:"entry,omitempty" json:"entry,omitempty"` + Current string `xml:"current,attr,omitempty" json:"current,omitempty"` + Position int64 `xml:"position,attr,omitempty" json:"position,omitempty"` + Username string `xml:"username,attr" json:"username"` + Changed *time.Time `xml:"changed,attr,omitempty" json:"changed,omitempty"` + ChangedBy string `xml:"changedBy,attr" json:"changedBy"` +} diff --git a/server/subsonic/responses/responses_test.go b/server/subsonic/responses/responses_test.go index 229675f71e3..fc07331d191 100644 --- a/server/subsonic/responses/responses_test.go +++ b/server/subsonic/responses/responses_test.go @@ -331,4 +331,39 @@ var _ = Describe("Responses", func() { }) }) + + Describe("PlayQueue", func() { + BeforeEach(func() { + response.PlayQueue = &PlayQueue{} + }) + + Context("without data", func() { + It("should match .XML", func() { + Expect(xml.Marshal(response)).To(MatchSnapshot()) + }) + It("should match .JSON", func() { + Expect(json.Marshal(response)).To(MatchSnapshot()) + }) + }) + + Context("with data", func() { + BeforeEach(func() { + response.PlayQueue.Username = "user1" + response.PlayQueue.Current = "111" + response.PlayQueue.Position = 243 + response.PlayQueue.Changed = &time.Time{} + response.PlayQueue.ChangedBy = "a_client" + child := make([]Child, 1) + child[0] = Child{Id: "1", Title: "title", IsDir: false} + response.PlayQueue.Entry = child + + }) + It("should match .XML", func() { + Expect(xml.Marshal(response)).To(MatchSnapshot()) + }) + It("should match .JSON", func() { + Expect(json.Marshal(response)).To(MatchSnapshot()) + }) + }) + }) })