Spotify: Loves export

This commit is contained in:
Philipp Wolfer 2023-11-22 11:52:28 +01:00
parent ed9debc127
commit 2e6319d296
No known key found for this signature in database
GPG key ID: 8FDF744D4919943B
3 changed files with 212 additions and 38 deletions

View file

@ -51,3 +51,16 @@ func TestSpotifyListenToListen(t *testing.T) {
assert.Equal(t, []string{"https://open.spotify.com/artist/101HSR6JTJqe3DBh6rb8kz"}, info["spotify_artist_ids"])
assert.Equal(t, []string{"https://open.spotify.com/artist/101HSR6JTJqe3DBh6rb8kz"}, info["spotify_album_artist_ids"])
}
func TestSavedTrackToLove(t *testing.T) {
data, err := os.ReadFile("testdata/track.json")
require.NoError(t, err)
track := spotify.SavedTrack{}
err = json.Unmarshal(data, &track)
require.NoError(t, err)
love := track.ToLove()
created, _ := time.Parse(time.RFC3339, "2022-02-13T21:46:08Z")
assert.Equal(t, created, love.Created)
assert.Equal(t, time.Duration(187680*time.Millisecond), love.Duration)
assert.Equal(t, "Death to the Holy", love.TrackName)
}