tests
This commit is contained in:
parent
4f527f3747
commit
e19803323a
@ -4,7 +4,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSong(t *testing.T) {
|
func TestSongDeduplicate(t *testing.T) {
|
||||||
song := Song{
|
song := Song{
|
||||||
Name: "song_a",
|
Name: "song_a",
|
||||||
Album: Album{
|
Album: Album{
|
||||||
@ -16,8 +16,8 @@ func TestSong(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Artists: []Artist{
|
Artists: []Artist{
|
||||||
{Name: "artist_a"},
|
{Name: "artist a"},
|
||||||
{Name: "artist_a"},
|
{Name: "artist a"},
|
||||||
{Name: "artist_b"},
|
{Name: "artist_b"},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -32,3 +32,61 @@ func TestSong(t *testing.T) {
|
|||||||
t.Errorf(`the two artists with the same names in the album have to be merged, %d`, len(compiled.Album.Artists))
|
t.Errorf(`the two artists with the same names in the album have to be merged, %d`, len(compiled.Album.Artists))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSongUnify(t *testing.T) {
|
||||||
|
song := Song{
|
||||||
|
Name: " foo Bar BAZ",
|
||||||
|
Album: Album{
|
||||||
|
Name: " foo",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
compiled := song.Compile().(Song)
|
||||||
|
|
||||||
|
if compiled.UnifiedName != "foo bar baz" {
|
||||||
|
t.Errorf(`the song name doesn't get compiled properly`)
|
||||||
|
}
|
||||||
|
|
||||||
|
if compiled.Album.UnifiedName != "foo" {
|
||||||
|
t.Errorf(`the album name in the song isn't unified`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestAlbumDeduplicate(t *testing.T) {
|
||||||
|
album := Album{
|
||||||
|
Name: "album_a",
|
||||||
|
Songs: []Song{
|
||||||
|
{Name: "song a"},
|
||||||
|
{Name: "song a"},
|
||||||
|
{Name: "song_b"},
|
||||||
|
{Name: "song_c"},
|
||||||
|
{Name: "song_d"},
|
||||||
|
{Name: "song a"},
|
||||||
|
},
|
||||||
|
Artists: []Artist{
|
||||||
|
{Name: "artist_a"},
|
||||||
|
{
|
||||||
|
Name: "artist_a",
|
||||||
|
Albums: []Album{
|
||||||
|
{Name: "album_a"},
|
||||||
|
{Name: "album_b"},
|
||||||
|
{Name: "album_a"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
compiled := album.Compile().(Album)
|
||||||
|
|
||||||
|
if len(compiled.Songs) != 4 {
|
||||||
|
t.Errorf(`didn't properly merge songs`)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(compiled.Artists) != 1 {
|
||||||
|
t.Errorf(`didn't properly merge artists`)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(compiled.Artists[0].Albums) != 2 {
|
||||||
|
t.Errorf(`didn't properly merge or deduplicate albums`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user