Fix marshaling for genres.

This commit is contained in:
Caio Cotts
2023-11-21 20:09:12 -05:00
committed by Deluan Quintão
parent 5d1493e845
commit bb7186ce2f
10 changed files with 233 additions and 83 deletions
+50 -1
View File
@@ -121,6 +121,17 @@ var _ = Describe("Responses", func() {
})
Describe("Child", func() {
Context("without data", func() {
BeforeEach(func() {
response.Directory = &Directory{Child: []Child{{Id: "1"}}}
})
It("should match .XML", func() {
Expect(xml.MarshalIndent(response, "", " ")).To(MatchSnapshot())
})
It("should match .JSON", func() {
Expect(json.MarshalIndent(response, "", " ")).To(MatchSnapshot())
})
})
Context("with data", func() {
BeforeEach(func() {
response.Directory = &Directory{Id: "1", Name: "N"}
@@ -130,7 +141,8 @@ var _ = Describe("Responses", func() {
Id: "1", IsDir: true, Title: "title", Album: "album", Artist: "artist", Track: 1,
Year: 1985, Genre: "Rock", CoverArt: "1", Size: 8421341, ContentType: "audio/flac",
Suffix: "flac", TranscodedContentType: "audio/mpeg", TranscodedSuffix: "mp3",
Duration: 146, BitRate: 320, Starred: &t,
Duration: 146, BitRate: 320, Starred: &t, Genres: []ItemGenre{{Name: "rock"}, {Name: "progressive"}},
Comment: "a comment", Bpm: 127,
}
response.Directory.Child = child
})
@@ -144,6 +156,43 @@ var _ = Describe("Responses", func() {
})
})
Describe("AlbumWithSongsID3", func() {
BeforeEach(func() {
response.AlbumWithSongsID3 = &AlbumWithSongsID3{}
})
Context("without data", func() {
It("should match .XML", func() {
Expect(xml.MarshalIndent(response, "", " ")).To(MatchSnapshot())
})
It("should match .JSON", func() {
Expect(json.MarshalIndent(response, "", " ")).To(MatchSnapshot())
})
})
Context("with data", func() {
BeforeEach(func() {
album := AlbumID3{Id: "1", Name: "album", Artist: "artist", Genre: "rock",
Genres: []ItemGenre{{Name: "rock"}, {Name: "progressive"}}, MusicBrainzId: "1234"}
t := time.Date(2016, 03, 2, 20, 30, 0, 0, time.UTC)
songs := []Child{{
Id: "1", IsDir: true, Title: "title", Album: "album", Artist: "artist", Track: 1,
Year: 1985, Genre: "Rock", CoverArt: "1", Size: 8421341, ContentType: "audio/flac",
Suffix: "flac", TranscodedContentType: "audio/mpeg", TranscodedSuffix: "mp3",
Duration: 146, BitRate: 320, Starred: &t, Genres: []ItemGenre{{Name: "rock"}, {Name: "progressive"}},
Comment: "a comment", Bpm: 127,
}}
response.AlbumWithSongsID3.AlbumID3 = album
response.AlbumWithSongsID3.Song = songs
})
It("should match .XML", func() {
Expect(xml.MarshalIndent(response, "", " ")).To(MatchSnapshot())
})
It("should match .JSON", func() {
Expect(json.MarshalIndent(response, "", " ")).To(MatchSnapshot())
})
})
})
Describe("Directory", func() {
BeforeEach(func() {
response.Directory = &Directory{Id: "1", Name: "N"}