Some checks failed
Pipeline: Test, Lint, Build / Get version info (push) Has been cancelled
Pipeline: Test, Lint, Build / Lint Go code (push) Has been cancelled
Pipeline: Test, Lint, Build / Test Go code (push) Has been cancelled
Pipeline: Test, Lint, Build / Test JS code (push) Has been cancelled
Pipeline: Test, Lint, Build / Lint i18n files (push) Has been cancelled
Pipeline: Test, Lint, Build / Check Docker configuration (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (darwin/amd64) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (darwin/arm64) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (linux/386) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (linux/amd64) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (linux/arm/v5) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (linux/arm/v6) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (linux/arm/v7) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (linux/arm64) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (windows/386) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (windows/amd64) (push) Has been cancelled
Pipeline: Test, Lint, Build / Push to GHCR (push) Has been cancelled
Pipeline: Test, Lint, Build / Push to Docker Hub (push) Has been cancelled
Pipeline: Test, Lint, Build / Cleanup digest artifacts (push) Has been cancelled
Pipeline: Test, Lint, Build / Build Windows installers (push) Has been cancelled
Pipeline: Test, Lint, Build / Package/Release (push) Has been cancelled
Pipeline: Test, Lint, Build / Upload Linux PKG (push) Has been cancelled
Close stale issues and PRs / stale (push) Has been cancelled
POEditor import / update-translations (push) Has been cancelled
56 lines
1.8 KiB
Go
56 lines
1.8 KiB
Go
package model
|
|
|
|
import (
|
|
"github.com/navidrome/navidrome/consts"
|
|
. "github.com/onsi/ginkgo/v2"
|
|
. "github.com/onsi/gomega"
|
|
)
|
|
|
|
var _ = Describe("fixAlbumArtist", func() {
|
|
var album Album
|
|
BeforeEach(func() {
|
|
album = Album{Participants: Participants{}}
|
|
})
|
|
Context("Non-Compilations", func() {
|
|
BeforeEach(func() {
|
|
album.Compilation = false
|
|
album.Participants.Add(RoleArtist, Artist{ID: "ar-123", Name: "Sparks"})
|
|
})
|
|
It("returns the track artist if no album artist is specified", func() {
|
|
fixAlbumArtist(&album)
|
|
Expect(album.AlbumArtistID).To(Equal("ar-123"))
|
|
Expect(album.AlbumArtist).To(Equal("Sparks"))
|
|
})
|
|
It("returns the album artist if it is specified", func() {
|
|
album.AlbumArtist = "Sparks Brothers"
|
|
album.AlbumArtistID = "ar-345"
|
|
fixAlbumArtist(&album)
|
|
Expect(album.AlbumArtistID).To(Equal("ar-345"))
|
|
Expect(album.AlbumArtist).To(Equal("Sparks Brothers"))
|
|
})
|
|
})
|
|
Context("Compilations", func() {
|
|
BeforeEach(func() {
|
|
album.Compilation = true
|
|
album.Name = "Sgt. Pepper Knew My Father"
|
|
album.AlbumArtistID = "ar-000"
|
|
album.AlbumArtist = "The Beatles"
|
|
})
|
|
|
|
It("returns VariousArtists if there's more than one album artist", func() {
|
|
album.Participants.Add(RoleAlbumArtist, Artist{ID: "ar-123", Name: "Sparks"})
|
|
album.Participants.Add(RoleAlbumArtist, Artist{ID: "ar-345", Name: "The Beach"})
|
|
fixAlbumArtist(&album)
|
|
Expect(album.AlbumArtistID).To(Equal(consts.VariousArtistsID))
|
|
Expect(album.AlbumArtist).To(Equal(consts.VariousArtists))
|
|
})
|
|
|
|
It("returns the sole album artist if they are the same", func() {
|
|
album.Participants.Add(RoleAlbumArtist, Artist{ID: "ar-000", Name: "The Beatles"})
|
|
fixAlbumArtist(&album)
|
|
Expect(album.AlbumArtistID).To(Equal("ar-000"))
|
|
Expect(album.AlbumArtist).To(Equal("The Beatles"))
|
|
})
|
|
})
|
|
})
|