artist tests
This commit is contained in:
parent
8fc6d69d45
commit
60abe03885
@ -102,3 +102,83 @@ func TestAlbumUnify(t *testing.T) {
|
|||||||
t.Errorf(`the song name doesn't get compiled properly`)
|
t.Errorf(`the song name doesn't get compiled properly`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestArtistDeduplicate(t *testing.T) {
|
||||||
|
artist := Artist{
|
||||||
|
Name: "main_artist",
|
||||||
|
Albums: []Album{
|
||||||
|
{Name: "concept_album"},
|
||||||
|
{
|
||||||
|
Name: "concept_album",
|
||||||
|
Artists: []Artist{
|
||||||
|
{
|
||||||
|
Name: "main_artist",
|
||||||
|
Albums: []Album{
|
||||||
|
{Name: "concept_album", Songs: []Song{{Name: "song_x"}, {Name: "song_x"}}},
|
||||||
|
{Name: "other_album"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{Name: "featured_artist"},
|
||||||
|
{Name: "featured_artist"},
|
||||||
|
},
|
||||||
|
Songs: []Song{
|
||||||
|
{
|
||||||
|
Name: "complex_song",
|
||||||
|
Artists: []Artist{
|
||||||
|
{Name: "main_artist"},
|
||||||
|
{Name: "featured_artist"},
|
||||||
|
{Name: "main_artist"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
compiled := artist.Compile().(Artist)
|
||||||
|
|
||||||
|
if len(compiled.Albums) != 1 {
|
||||||
|
t.Errorf("should deduplicate album artists, got %d", len(compiled.Albums[0].Artists))
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(compiled.Albums[0].Artists) != 2 {
|
||||||
|
t.Errorf("should deduplicate album artists, got %d", len(compiled.Albums[0].Artists))
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(compiled.Albums[0].Artists[0].Albums) != 2 {
|
||||||
|
t.Errorf("should deduplicate nested albums, got %d", len(compiled.Albums[0].Artists[0].Albums))
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(compiled.Albums[0].Songs[0].Artists) != 2 {
|
||||||
|
t.Errorf("should deduplicate song artists, got %d", len(compiled.Albums[0].Songs[0].Artists))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestArtistUnify(t *testing.T) {
|
||||||
|
artist := Artist{
|
||||||
|
Name: " The BEATLES ",
|
||||||
|
Albums: []Album{
|
||||||
|
{
|
||||||
|
Name: " Abbey Road ",
|
||||||
|
Songs: []Song{
|
||||||
|
{Name: "Come Together "},
|
||||||
|
{Name: "Something"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
compiled := artist.Compile().(Artist)
|
||||||
|
|
||||||
|
if compiled.UnifiedName != "the beatles" {
|
||||||
|
t.Errorf("artist name not unified properly, got: %s", compiled.UnifiedName)
|
||||||
|
}
|
||||||
|
|
||||||
|
if compiled.Albums[0].UnifiedName != "abbey road" {
|
||||||
|
t.Errorf("album name in artist not unified properly, got: %s", compiled.Albums[0].UnifiedName)
|
||||||
|
}
|
||||||
|
|
||||||
|
if compiled.Albums[0].Songs[0].UnifiedName != "come together" {
|
||||||
|
t.Errorf("song name in artist album not unified properly, got: %s", compiled.Albums[0].Songs[0].UnifiedName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user