Add discs to album
This commit is contained in:
@@ -3,6 +3,7 @@ package persistence
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/fatih/structs"
|
||||
"github.com/navidrome/navidrome/log"
|
||||
"github.com/navidrome/navidrome/model"
|
||||
"github.com/navidrome/navidrome/model/request"
|
||||
@@ -55,4 +56,37 @@ var _ = Describe("AlbumRepository", func() {
|
||||
}))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("dbAlbum mapping", func() {
|
||||
var a *model.Album
|
||||
BeforeEach(func() {
|
||||
a = &model.Album{ID: "1", Name: "name", ArtistID: "2"}
|
||||
})
|
||||
It("maps empty discs field", func() {
|
||||
a.Discs = model.Discs{}
|
||||
dba := dbAlbum{Album: a}
|
||||
|
||||
m := structs.Map(dba)
|
||||
Expect(dba.PostMapArgs(m)).To(Succeed())
|
||||
Expect(m).To(HaveKeyWithValue("discs", `{}`))
|
||||
|
||||
other := dbAlbum{Album: &model.Album{ID: "1", Name: "name"}, Discs: "{}"}
|
||||
Expect(other.PostScan()).To(Succeed())
|
||||
|
||||
Expect(other.Album.Discs).To(Equal(a.Discs))
|
||||
})
|
||||
It("maps the discs field", func() {
|
||||
a.Discs = model.Discs{"1": "disc1", "2": "disc2"}
|
||||
dba := dbAlbum{Album: a}
|
||||
|
||||
m := structs.Map(dba)
|
||||
Expect(dba.PostMapArgs(m)).To(Succeed())
|
||||
Expect(m).To(HaveKeyWithValue("discs", `{"1":"disc1","2":"disc2"}`))
|
||||
|
||||
other := dbAlbum{Album: &model.Album{ID: "1", Name: "name"}, Discs: m["discs"].(string)}
|
||||
Expect(other.PostScan()).To(Succeed())
|
||||
|
||||
Expect(other.Album.Discs).To(Equal(a.Discs))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user