diff --git a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Bookmarks with data should match .JSON b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Bookmarks with data should match .JSON new file mode 100644 index 000000000..ae9fc6fa2 --- /dev/null +++ b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Bookmarks with data should match .JSON @@ -0,0 +1 @@ +{"status":"ok","version":"1.8.0","type":"navidrome","serverVersion":"v0.0.0","bookmarks":{"bookmark":[{"entry":[{"id":"1","isDir":false,"title":"title","isVideo":false}],"position":123,"username":"user2","comment":"a comment","created":"0001-01-01T00:00:00Z","changed":"0001-01-01T00:00:00Z"}]}} diff --git a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Bookmarks with data should match .XML b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Bookmarks with data should match .XML new file mode 100644 index 000000000..cda506634 --- /dev/null +++ b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Bookmarks with data should match .XML @@ -0,0 +1 @@ + diff --git a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Bookmarks without data should match .JSON b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Bookmarks without data should match .JSON new file mode 100644 index 000000000..06316950a --- /dev/null +++ b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Bookmarks without data should match .JSON @@ -0,0 +1 @@ +{"status":"ok","version":"1.8.0","type":"navidrome","serverVersion":"v0.0.0","bookmarks":{}} diff --git a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Bookmarks without data should match .XML b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Bookmarks without data should match .XML new file mode 100644 index 000000000..746ee55b3 --- /dev/null +++ b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Bookmarks without data should match .XML @@ -0,0 +1 @@ + diff --git a/server/subsonic/responses/responses.go b/server/subsonic/responses/responses.go index eb529ea14..447da51a6 100644 --- a/server/subsonic/responses/responses.go +++ b/server/subsonic/responses/responses.go @@ -40,6 +40,7 @@ type Subsonic struct { ArtistInfo2 *ArtistInfo2 `xml:"artistInfo2,omitempty" json:"artistInfo2,omitempty"` PlayQueue *PlayQueue `xml:"playQueue,omitempty" json:"playQueue,omitempty"` + Bookmarks *Bookmarks `xml:"bookmarks,omitempty" json:"bookmarks,omitempty"` } type JsonWrapper struct { @@ -304,3 +305,16 @@ type PlayQueue struct { Changed *time.Time `xml:"changed,attr,omitempty" json:"changed,omitempty"` ChangedBy string `xml:"changedBy,attr" json:"changedBy"` } + +type Bookmark struct { + Entry []Child `xml:"entry,omitempty" json:"entry,omitempty"` + Position int64 `xml:"position,attr,omitempty" json:"position,omitempty"` + Username string `xml:"username,attr" json:"username"` + Comment string `xml:"comment,attr" json:"comment"` + Created time.Time `xml:"created,attr" json:"created"` + Changed time.Time `xml:"changed,attr" json:"changed"` +} + +type Bookmarks struct { + Bookmark []Bookmark `xml:"bookmark,omitempty" json:"bookmark,omitempty"` +} diff --git a/server/subsonic/responses/responses_test.go b/server/subsonic/responses/responses_test.go index fc07331d1..729d73d7c 100644 --- a/server/subsonic/responses/responses_test.go +++ b/server/subsonic/responses/responses_test.go @@ -356,7 +356,41 @@ var _ = Describe("Responses", func() { 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()) + }) + }) + }) + Describe("Bookmarks", func() { + BeforeEach(func() { + response.Bookmarks = &Bookmarks{} + }) + + 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() { + bmk := Bookmark{ + Position: 123, + Username: "user2", + Comment: "a comment", + Created: time.Time{}, + Changed: time.Time{}, + } + bmk.Entry = []Child{{Id: "1", Title: "title", IsDir: false}} + response.Bookmarks.Bookmark = []Bookmark{bmk} }) It("should match .XML", func() { Expect(xml.Marshal(response)).To(MatchSnapshot())