From d24709b5217d66a7d09da69b75ede0d4c6807c79 Mon Sep 17 00:00:00 2001 From: Deluan Date: Sun, 25 Oct 2020 21:48:21 -0400 Subject: [PATCH] Add getScanStatus Subsonic response --- ...es ScanStatus with data should match .JSON | 1 + ...ses ScanStatus with data should match .XML | 1 + ...ScanStatus without data should match .JSON | 1 + ... ScanStatus without data should match .XML | 1 + server/subsonic/responses/responses.go | 10 +++++-- server/subsonic/responses/responses_test.go | 30 +++++++++++++++++++ 6 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses ScanStatus with data should match .JSON create mode 100644 server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses ScanStatus with data should match .XML create mode 100644 server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses ScanStatus without data should match .JSON create mode 100644 server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses ScanStatus without data should match .XML diff --git a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses ScanStatus with data should match .JSON b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses ScanStatus with data should match .JSON new file mode 100644 index 000000000..92b81193e --- /dev/null +++ b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses ScanStatus with data should match .JSON @@ -0,0 +1 @@ +{"status":"ok","version":"1.8.0","type":"navidrome","serverVersion":"v0.0.0","scanStatus":{"scanning":true,"count":123}} diff --git a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses ScanStatus with data should match .XML b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses ScanStatus with data should match .XML new file mode 100644 index 000000000..e1029107f --- /dev/null +++ b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses ScanStatus with data should match .XML @@ -0,0 +1 @@ + diff --git a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses ScanStatus without data should match .JSON b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses ScanStatus without data should match .JSON new file mode 100644 index 000000000..1aa0cf513 --- /dev/null +++ b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses ScanStatus without data should match .JSON @@ -0,0 +1 @@ +{"status":"ok","version":"1.8.0","type":"navidrome","serverVersion":"v0.0.0","scanStatus":{"scanning":false,"count":0}} diff --git a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses ScanStatus without data should match .XML b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses ScanStatus without data should match .XML new file mode 100644 index 000000000..7add568de --- /dev/null +++ b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses ScanStatus without data should match .XML @@ -0,0 +1 @@ + diff --git a/server/subsonic/responses/responses.go b/server/subsonic/responses/responses.go index 65736ec55..cc77f4e61 100644 --- a/server/subsonic/responses/responses.go +++ b/server/subsonic/responses/responses.go @@ -42,8 +42,9 @@ type Subsonic struct { SimilarSongs2 *SimilarSongs2 `xml:"similarSongs2,omitempty" json:"similarSongs2,omitempty"` TopSongs *TopSongs `xml:"topSongs,omitempty" json:"topSongs,omitempty"` - PlayQueue *PlayQueue `xml:"playQueue,omitempty" json:"playQueue,omitempty"` - Bookmarks *Bookmarks `xml:"bookmarks,omitempty" json:"bookmarks,omitempty"` + PlayQueue *PlayQueue `xml:"playQueue,omitempty" json:"playQueue,omitempty"` + Bookmarks *Bookmarks `xml:"bookmarks,omitempty" json:"bookmarks,omitempty"` + ScanStatus *ScanStatus `xml:"scanStatus,omitempty" json:"scanStatus,omitempty"` } type JsonWrapper struct { @@ -331,3 +332,8 @@ type Bookmark struct { type Bookmarks struct { Bookmark []Bookmark `xml:"bookmark,omitempty" json:"bookmark,omitempty"` } + +type ScanStatus struct { + Scanning bool `xml:"scanning,attr" json:"scanning"` + Count int64 `xml:"count,attr" json:"count"` +} diff --git a/server/subsonic/responses/responses_test.go b/server/subsonic/responses/responses_test.go index 33fa6e8f9..1877fa67e 100644 --- a/server/subsonic/responses/responses_test.go +++ b/server/subsonic/responses/responses_test.go @@ -487,4 +487,34 @@ var _ = Describe("Responses", func() { }) }) }) + + Describe("ScanStatus", func() { + BeforeEach(func() { + response.ScanStatus = &ScanStatus{} + }) + + 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.ScanStatus = &ScanStatus{ + Scanning: true, + Count: 123, + } + }) + It("should match .XML", func() { + Expect(xml.Marshal(response)).To(MatchSnapshot()) + }) + It("should match .JSON", func() { + Expect(json.Marshal(response)).To(MatchSnapshot()) + }) + }) + }) })