Convert internal disc number representation to int

This commit is contained in:
Deluan 2023-12-08 22:07:58 -05:00
parent 2c9035fdd0
commit 465cc091b0
5 changed files with 11 additions and 31 deletions

View file

@ -1,7 +1,6 @@
package model
import (
"strconv"
"time"
"github.com/navidrome/navidrome/utils/slice"
@ -62,13 +61,14 @@ func (a Album) CoverArtID() ArtworkID {
return artworkIDFromAlbum(a)
}
type Discs map[string]string
type Discs map[int]string
// Add adds a disc to the Discs map. If the map is nil, it is initialized.
func (d *Discs) Add(discNumber int, discSubtitle string) {
if *d == nil {
*d = Discs{}
}
(*d)[strconv.Itoa(discNumber)] = discSubtitle
(*d)[discNumber] = discSubtitle
}
type DiscID struct {

View file

@ -139,7 +139,7 @@ var _ = Describe("MediaFiles", func() {
})
It("sets the correct Discs", func() {
album := mfs.ToAlbum()
Expect(album.Discs).To(Equal(Discs{"1": "DiscSubtitle"}))
Expect(album.Discs).To(Equal(Discs{1: "DiscSubtitle"}))
})
})
When("we have multiple discs", func() {
@ -148,7 +148,7 @@ var _ = Describe("MediaFiles", func() {
})
It("sets the correct Discs", func() {
album := mfs.ToAlbum()
Expect(album.Discs).To(Equal(Discs{"1": "DiscSubtitle", "2": "DiscSubtitle2"}))
Expect(album.Discs).To(Equal(Discs{1: "DiscSubtitle", 2: "DiscSubtitle2"}))
})
})
})