mirror of
https://git.sr.ht/~phw/scotty
synced 2025-05-05 07:57:06 +02:00
Reduced redundancy in model conversions and consistent naming
This commit is contained in:
parent
e29d8e2a63
commit
cac88f316b
10 changed files with 107 additions and 107 deletions
|
@ -28,13 +28,13 @@ import (
|
|||
"go.uploadedlobster.com/scotty/backends/spotify"
|
||||
)
|
||||
|
||||
func TestSpotifyListenToListen(t *testing.T) {
|
||||
func TestSpotifyListenAsListen(t *testing.T) {
|
||||
data, err := os.ReadFile("testdata/listen.json")
|
||||
require.NoError(t, err)
|
||||
spListen := spotify.Listen{}
|
||||
err = json.Unmarshal(data, &spListen)
|
||||
require.NoError(t, err)
|
||||
listen := spListen.ToListen()
|
||||
listen := spListen.AsListen()
|
||||
listenedAt, _ := time.Parse(time.RFC3339, "2023-11-21T15:24:33.361Z")
|
||||
assert.Equal(t, listenedAt, listen.ListenedAt)
|
||||
assert.Equal(t, time.Duration(413826*time.Millisecond), listen.Duration)
|
||||
|
@ -53,13 +53,13 @@ func TestSpotifyListenToListen(t *testing.T) {
|
|||
assert.Equal(t, []string{"https://open.spotify.com/artist/101HSR6JTJqe3DBh6rb8kz"}, info["spotify_album_artist_ids"])
|
||||
}
|
||||
|
||||
func TestSavedTrackToLove(t *testing.T) {
|
||||
func TestSavedTrackAsLove(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()
|
||||
love := track.AsLove()
|
||||
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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue