diff --git a/album.go b/album.go index 8c563bf..f810c59 100644 --- a/album.go +++ b/album.go @@ -86,7 +86,7 @@ type FullAlbum struct { // The popularity of the album, represented as an integer between 0 and 100, // with 100 being the most popular. Popularity of an album is calculated // from the popularity of the album's individual tracks. - Popularity int `json:"popularity"` + Popularity Numeric `json:"popularity"` Tracks SimpleTrackPage `json:"tracks"` ExternalIDs map[string]string `json:"external_ids"` } diff --git a/artist.go b/artist.go index 1987891..5eceff7 100644 --- a/artist.go +++ b/artist.go @@ -22,7 +22,7 @@ type FullArtist struct { SimpleArtist // The popularity of the artist, expressed as an integer between 0 and 100. // The artist's popularity is calculated from the popularity of the artist's tracks. - Popularity int `json:"popularity"` + Popularity Numeric `json:"popularity"` // A list of genres the artist is associated with. For example, "Prog Rock" // or "Post-Grunge". If not yet classified, the slice is empty. Genres []string `json:"genres"` diff --git a/artist_test.go b/artist_test.go index f1d4871..cf6537b 100644 --- a/artist_test.go +++ b/artist_test.go @@ -56,17 +56,17 @@ const albumsResponse = ` "href" : "https://api.spotify.com/v1/albums/1WXM7DYQRT7QX8AKBJRfK9", "id" : "1WXM7DYQRT7QX8AKBJRfK9", "images" : [ { - "height" : 640, + "height" : 640.0, "url" : "https://i.scdn.co/image/590dbe5504d2898c120b942bee2b699404783896", - "width" : 640 + "width" : 640.0 }, { - "height" : 300, + "height" : 300.0, "url" : "https://i.scdn.co/image/9a4db24b1930e8683b4dfd19c7bd2a40672c6718", - "width" : 300 + "width" : 300.0 }, { - "height" : 64, + "height" : 64.0, "url" : "https://i.scdn.co/image/d5cfc167e03ed328ae7dfa9b56d3628d81b6831b", - "width" : 64 + "width" : 64.0 } ], "name" : "The Days / Nights", "type" : "album", @@ -136,6 +136,26 @@ func TestRelatedArtists(t *testing.T) { } } +func TestRelatedArtistsWithFloats(t *testing.T) { + client, server := testClientFile(http.StatusOK, "test_data/related_artists_with_floats.txt") + defer server.Close() + + artists, err := client.GetRelatedArtists(context.Background(), ID("43ZHCT0cAZBISjO8DG9PnE")) + if err != nil { + t.Fatal(err) + } + if count := len(artists); count != 20 { + t.Fatalf("Got %d artists, wanted 20\n", count) + } + a2 := artists[2] + if a2.Name != "Carl Perkins" { + t.Error("Expected Carl Perkins, got ", a2.Name) + } + if a2.Popularity != 54 { + t.Errorf("Expected popularity 54, got %d\n", a2.Popularity) + } +} + func TestArtistAlbumsFiltered(t *testing.T) { client, server := testClientString(http.StatusOK, albumsResponse) defer server.Close() diff --git a/audio_analysis.go b/audio_analysis.go index 7c84d8c..ffe13e3 100644 --- a/audio_analysis.go +++ b/audio_analysis.go @@ -49,7 +49,7 @@ type Section struct { KeyConfidence float64 `json:"key_confidence"` Mode Mode `json:"mode"` ModeConfidence float64 `json:"mode_confidence"` - TimeSignature int `json:"time_signature"` + TimeSignature Numeric `json:"time_signature"` TimeSignatureConfidence float64 `json:"time_signature_confidence"` } @@ -70,16 +70,16 @@ type AnalysisTrack struct { NumSamples int64 `json:"num_samples"` Duration float64 `json:"duration"` SampleMD5 string `json:"sample_md5"` - OffsetSeconds int `json:"offset_seconds"` - WindowSeconds int `json:"window_seconds"` + OffsetSeconds Numeric `json:"offset_seconds"` + WindowSeconds Numeric `json:"window_seconds"` AnalysisSampleRate int64 `json:"analysis_sample_rate"` - AnalysisChannels int `json:"analysis_channels"` + AnalysisChannels Numeric `json:"analysis_channels"` EndOfFadeIn float64 `json:"end_of_fade_in"` StartOfFadeOut float64 `json:"start_of_fade_out"` Loudness float64 `json:"loudness"` Tempo float64 `json:"tempo"` TempoConfidence float64 `json:"tempo_confidence"` - TimeSignature int `json:"time_signature"` + TimeSignature Numeric `json:"time_signature"` TimeSignatureConfidence float64 `json:"time_signature_confidence"` Key Key `json:"key"` KeyConfidence float64 `json:"key_confidence"` diff --git a/audio_features.go b/audio_features.go index 3154e69..df13802 100644 --- a/audio_features.go +++ b/audio_features.go @@ -23,7 +23,7 @@ type AudioFeatures struct { // and 1.0 is most danceable. Danceability float32 `json:"danceability"` // The length of the track in milliseconds. - Duration int `json:"duration_ms"` + Duration Numeric `json:"duration_ms"` // Energy is a measure from 0.0 to 1.0 and represents a perceptual measure // of intensity and activity. Typically, energetic tracks feel fast, loud, // and noisy. @@ -39,7 +39,7 @@ type AudioFeatures struct { Instrumentalness float32 `json:"instrumentalness"` // The key the track is in. Integers map to pitches using standard Pitch Class notation // (https://en.wikipedia.org/wiki/Pitch_class). - Key int `json:"key"` + Key Numeric `json:"key"` // Detects the presence of an audience in the recording. Higher liveness // values represent an increased probability that the track was performed live. // A value above 0.8 provides strong likelihood that the track is live. @@ -49,7 +49,7 @@ type AudioFeatures struct { // loudness of tracks. Typical values range between -60 and 0 dB. Loudness float32 `json:"loudness"` // Mode indicates the modality (major or minor) of a track. - Mode int `json:"mode"` + Mode Numeric `json:"mode"` // Detects the presence of spoken words in a track. The more exclusively // speech-like the recording, the closer to 1.0 the speechiness will be. // Values above 0.66 describe tracks that are probably made entirely of @@ -61,7 +61,7 @@ type AudioFeatures struct { Tempo float32 `json:"tempo"` // An estimated overall time signature of a track. The time signature (meter) // is a notational convention to specify how many beats are in each bar (or measure). - TimeSignature int `json:"time_signature"` + TimeSignature Numeric `json:"time_signature"` // A link to the Web API endpoint providing full details of the track. TrackURL string `json:"track_href"` // The Spotify URI for the track. diff --git a/cursor.go b/cursor.go index 200f3ce..0d08ddc 100644 --- a/cursor.go +++ b/cursor.go @@ -20,11 +20,11 @@ type cursorPage struct { Endpoint string `json:"href"` // The maximum number of items returned, as set in the query // (or default value if unset). - Limit int `json:"limit"` + Limit Numeric `json:"limit"` // The URL to the next set of items. Next string `json:"next"` // The total number of items available to return. - Total int `json:"total"` + Total Numeric `json:"total"` // The cursor used to find the next set of items. Cursor Cursor `json:"cursors"` } diff --git a/page.go b/page.go index dbd5078..1e3ded2 100644 --- a/page.go +++ b/page.go @@ -23,12 +23,12 @@ type basePage struct { Endpoint string `json:"href"` // The maximum number of items in the response, as set // in the query (or default value if unset). - Limit int `json:"limit"` + Limit Numeric `json:"limit"` // The offset of the items returned, as set in the query // (or default value if unset). - Offset int `json:"offset"` + Offset Numeric `json:"offset"` // The total number of items available to return. - Total int `json:"total"` + Total Numeric `json:"total"` // The URL to the next page of items (if available). Next string `json:"next"` // The URL to the previous page of items (if available). diff --git a/page_test.go b/page_test.go index bdaa75c..c9c1d53 100644 --- a/page_test.go +++ b/page_test.go @@ -55,7 +55,7 @@ func TestClient_NextPage(t *testing.T) { assert.Equal(t, tt.ExpectedPath != "", wasCalled) if tt.Err == nil { assert.NoError(t, err) - assert.Equal(t, 100, tt.Input.Total) // value should be from original 600 + assert.Equal(t, 100, int(tt.Input.Total)) // value should be from original 600 } else { assert.EqualError(t, err, tt.Err.Error()) } @@ -110,7 +110,7 @@ func TestClient_PreviousPage(t *testing.T) { assert.Equal(t, tt.ExpectedPath != "", wasCalled) if tt.Err == nil { assert.NoError(t, err) - assert.Equal(t, 100, tt.Input.Total) // value should be from original 600 + assert.Equal(t, 100, int(tt.Input.Total)) // value should be from original 600 } else { assert.EqualError(t, err, tt.Err.Error()) } diff --git a/player.go b/player.go index 142e2da..34f11fc 100755 --- a/player.go +++ b/player.go @@ -24,7 +24,7 @@ type PlayerDevice struct { // Type of device, such as "Computer", "Smartphone" or "Speaker". Type string `json:"type"` // Volume The current volume in percent. - Volume int `json:"volume_percent"` + Volume Numeric `json:"volume_percent"` } // PlayerState contains information about the current playback. @@ -57,7 +57,7 @@ type CurrentlyPlaying struct { // PlaybackContext current context PlaybackContext PlaybackContext `json:"context"` // Progress into the currently playing track. - Progress int `json:"progress_ms"` + Progress Numeric `json:"progress_ms"` // Playing If something is currently playing. Playing bool `json:"is_playing"` // The currently playing track. Can be null. @@ -110,7 +110,7 @@ type PlayOptions struct { // Must be a positive number. Passing in a position that is greater // than the length of the track will cause the player to start playing the next song. // Defaults to 0, starting a track from the beginning. - PositionMs int `json:"position_ms,omitempty"` + PositionMs Numeric `json:"position_ms,omitempty"` } // RecentlyPlayedOptions describes options for the recently-played request. All @@ -120,7 +120,7 @@ type PlayOptions struct { type RecentlyPlayedOptions struct { // Limit is the maximum number of items to return. Must be no greater than // fifty. - Limit int + Limit Numeric // AfterEpochMs is a Unix epoch in milliseconds that describes a time after // which to return songs. diff --git a/playlist.go b/playlist.go index c74c2b0..80c59bf 100644 --- a/playlist.go +++ b/playlist.go @@ -18,7 +18,7 @@ type PlaylistTracks struct { // the playlist's tracks can be retrieved. Endpoint string `json:"href"` // The total number of tracks in the playlist. - Total uint `json:"total"` + Total Numeric `json:"total"` } // SimplePlaylist contains basic info about a Spotify playlist. @@ -621,14 +621,14 @@ func (c *Client) UserFollowsPlaylist(ctx context.Context, playlistID ID, userIDs type PlaylistReorderOptions struct { // The position of the first track to be reordered. // This field is required. - RangeStart int `json:"range_start"` + RangeStart Numeric `json:"range_start"` // The amount of tracks to be reordered. This field is optional. If // you don't set it, the value 1 will be used. - RangeLength int `json:"range_length,omitempty"` + RangeLength Numeric `json:"range_length,omitempty"` // The position where the tracks should be inserted. To reorder the // tracks to the end of the playlist, simply set this to the position // after the last track. This field is required. - InsertBefore int `json:"insert_before"` + InsertBefore Numeric `json:"insert_before"` // The playlist's snapshot ID against which you wish to make the changes. // This field is optional. SnapshotID string `json:"snapshot_id,omitempty"` diff --git a/recommendation.go b/recommendation.go index a205bb0..f881c45 100644 --- a/recommendation.go +++ b/recommendation.go @@ -30,12 +30,12 @@ type Recommendations struct { // RecommendationSeed represents a recommendation seed after // being processed by the Spotify API type RecommendationSeed struct { - AfterFilteringSize int `json:"afterFilteringSize"` - AfterRelinkingSize int `json:"afterRelinkingSize"` - Endpoint string `json:"href"` - ID ID `json:"id"` - InitialPoolSize int `json:"initialPoolSize"` - Type string `json:"type"` + AfterFilteringSize Numeric `json:"afterFilteringSize"` + AfterRelinkingSize Numeric `json:"afterRelinkingSize"` + Endpoint string `json:"href"` + ID ID `json:"id"` + InitialPoolSize Numeric `json:"initialPoolSize"` + Type string `json:"type"` } // MaxNumberOfSeeds allowed by Spotify for a recommendation request diff --git a/show.go b/show.go index 5c2bfd9..fb4a3f6 100644 --- a/show.go +++ b/show.go @@ -87,7 +87,7 @@ type EpisodePage struct { Description string `json:"description"` // The episode length in milliseconds. - Duration_ms int `json:"duration_ms"` + Duration_ms Numeric `json:"duration_ms"` // Whether or not the episode has explicit content // (true = yes it does; false = no it does not OR unknown). @@ -147,7 +147,7 @@ type ResumePointObject struct { FullyPlayed bool `json:"fully_played"` // The user’s most recent position in the episode in milliseconds. - ResumePositionMs int `json:"resume_position_ms"` + ResumePositionMs Numeric `json:"resume_position_ms"` } // ReleaseDateTime converts the show's ReleaseDate to a time.TimeValue. diff --git a/spotify.go b/spotify.go index c61f75b..63851d6 100644 --- a/spotify.go +++ b/spotify.go @@ -102,11 +102,24 @@ func (id *ID) String() string { return string(*id) } +// Numeric is a convenience type for handling numbers sent as either integers or floats. +type Numeric int + +// UnmarshalJSON unmarshals a JSON number (float or int) into the Numeric type. +func (n *Numeric) UnmarshalJSON(data []byte) error { + var f float64 + if err := json.Unmarshal(data, &f); err != nil { + return err + } + *n = Numeric(int(f)) + return nil +} + // Followers contains information about the number of people following a // particular artist or playlist. type Followers struct { // The total number of followers. - Count uint `json:"total"` + Count Numeric `json:"total"` // A link to the Web API endpoint providing full details of the followers, // or the empty string if this data is not available. Endpoint string `json:"href"` @@ -115,9 +128,9 @@ type Followers struct { // Image identifies an image associated with an item. type Image struct { // The image height, in pixels. - Height int `json:"height"` + Height Numeric `json:"height"` // The image width, in pixels. - Width int `json:"width"` + Width Numeric `json:"width"` // The source URL of the image. URL string `json:"url"` } @@ -222,7 +235,7 @@ func (c *Client) execute(req *http.Request, result interface{}, needsStatus ...i // If the context is cancelled, return the original error case <-time.After(retryDuration(resp)): continue - } + } } if resp.StatusCode == http.StatusNoContent { return nil diff --git a/test_data/find_track_with_floats.txt b/test_data/find_track_with_floats.txt new file mode 100644 index 0000000..0b4f0fc --- /dev/null +++ b/test_data/find_track_with_floats.txt @@ -0,0 +1,64 @@ +{ + "album" : { + "album_type" : "single", + "available_markets" : [ "AD", "AR", "AT", "AU", "BG", "BO", "BR", "CA", "CH", "CL", "CO", "CR", "CY", "CZ", "DE", "DO", "EC", "EE", "ES", "FI", "FR", "GR", "GT", "HK", "HN", "HU", "IE", "IT", "LI", "LT", "LV", "MC", "MT", "MX", "MY", "NI", "NO", "NZ", "PA", "PE", "PH", "PL", "PT", "PY", "RO", "SE", "SG", "SI", "SK", "SV", "TR", "TW", "UY" ], + "external_urls" : { + "spotify" : "https://open.spotify.com/album/3X33e7UII5loqrEgauOKEC" + }, + "href" : "https://api.spotify.com/v1/albums/3X33e7UII5loqrEgauOKEC", + "id" : "3X33e7UII5loqrEgauOKEC", + "images" : [ { + "height" : 640.0, + "url" : "https://i.scdn.co/image/c171113a197828a6ee8017d1ede2e78c9a7df654", + "width" : 640.0 + }, { + "height" : 300.0, + "url" : "https://i.scdn.co/image/de50cbd4f0e62be8d4ffd11c7d6f3c59d964bdb6", + "width" : 300.0 + }, { + "height" : 64.0, + "url" : "https://i.scdn.co/image/5a18558e39d542ec9d71345daafe89d5862aa67a", + "width" : 64.0 + } ], + "name" : "Timber", + "type" : "album", + "uri" : "spotify:album:3X33e7UII5loqrEgauOKEC" + }, + "artists" : [ { + "external_urls" : { + "spotify" : "https://open.spotify.com/artist/0TnOYISbd1XYRBk9myaseg" + }, + "href" : "https://api.spotify.com/v1/artists/0TnOYISbd1XYRBk9myaseg", + "id" : "0TnOYISbd1XYRBk9myaseg", + "name" : "Pitbull", + "type" : "artist", + "uri" : "spotify:artist:0TnOYISbd1XYRBk9myaseg" + }, { + "external_urls" : { + "spotify" : "https://open.spotify.com/artist/6LqNN22kT3074XbTVUrhzX" + }, + "href" : "https://api.spotify.com/v1/artists/6LqNN22kT3074XbTVUrhzX", + "id" : "6LqNN22kT3074XbTVUrhzX", + "name" : "Ke$ha", + "type" : "artist", + "uri" : "spotify:artist:6LqNN22kT3074XbTVUrhzX" + } ], + "available_markets" : [ "AD", "AR", "AT", "AU", "BG", "BO", "BR", "CA", "CH", "CL", "CO", "CR", "CY", "CZ", "DE", "DO", "EC", "EE", "ES", "FI", "FR", "GR", "GT", "HK", "HN", "HU", "IE", "IT", "LI", "LT", "LV", "MC", "MT", "MX", "MY", "NI", "NO", "NZ", "PA", "PE", "PH", "PL", "PT", "PY", "RO", "SE", "SG", "SI", "SK", "SV", "TR", "TW", "UY" ], + "disc_number" : 1.0, + "duration_ms" : 204053.0, + "explicit" : false, + "external_ids" : { + "isrc" : "USRC11301695" + }, + "external_urls" : { + "spotify" : "https://open.spotify.com/track/1zHlj4dQ8ZAtrayhuDDmkY" + }, + "href" : "https://api.spotify.com/v1/tracks/1zHlj4dQ8ZAtrayhuDDmkY", + "id" : "1zHlj4dQ8ZAtrayhuDDmkY", + "name" : "Timber", + "popularity" : 85.0, + "preview_url" : "https://p.scdn.co/mp3-preview/18d0a45538122fbe33f22604d0e5608789c10ae4", + "track_number" : 1.0, + "type" : "track", + "uri" : "spotify:track:1zHlj4dQ8ZAtrayhuDDmkY" +} diff --git a/test_data/related_artists_with_floats.txt b/test_data/related_artists_with_floats.txt new file mode 100644 index 0000000..0955b6a --- /dev/null +++ b/test_data/related_artists_with_floats.txt @@ -0,0 +1,639 @@ +{ + "artists" : [ { + "external_urls" : { + "spotify" : "https://open.spotify.com/artist/4ACplpEqD6JIVgKrafauzs" + }, + "followers" : { + "href" : null, + "total" : 33920.0 + }, + "genres" : [ "brill building pop", "rock-and-roll", "rockabilly" ], + "href" : "https://api.spotify.com/v1/artists/4ACplpEqD6JIVgKrafauzs", + "id" : "4ACplpEqD6JIVgKrafauzs", + "images" : [ { + "height" : 1035.0, + "url" : "https://i.scdn.co/image/bf582c9e540c2f12771cfd032f592d31697cfae9", + "width" : 1000.0 + }, { + "height" : 662.0, + "url" : "https://i.scdn.co/image/da7c23421146985b7e1583d3bc09ecba9f7ac5c6", + "width" : 640.0 + }, { + "height" : 207.0, + "url" : "https://i.scdn.co/image/b430dbc0ed1d6926b9088440683d15270e5154cc", + "width" : 200.0 + }, { + "height" : 66.0, + "url" : "https://i.scdn.co/image/985afca7544c6933b7e7ada2018c4ed0b4bba7a0", + "width" : 64.0 + } ], + "name" : "The Everly Brothers", + "popularity" : 67.0, + "type" : "artist", + "uri" : "spotify:artist:4ACplpEqD6JIVgKrafauzs" + }, { + "external_urls" : { + "spotify" : "https://open.spotify.com/artist/5ZKMPRDHc7qElVJFh3uRqB" + }, + "followers" : { + "href" : null, + "total" : 19340.0 + }, + "genres" : [ "rockabilly" ], + "href" : "https://api.spotify.com/v1/artists/5ZKMPRDHc7qElVJFh3uRqB", + "id" : "5ZKMPRDHc7qElVJFh3uRqB", + "images" : [ { + "height" : 997.0, + "url" : "https://i.scdn.co/image/beff5827580bcc4d129cbc0872768095eeba8c14", + "width" : 1000.0 + }, { + "height" : 638.0, + "url" : "https://i.scdn.co/image/dbabf703779789917c4dd1c0e54da62c7a45ce92", + "width" : 640.0 + }, { + "height" : 199.0, + "url" : "https://i.scdn.co/image/74761c343bec27c814b8e44e4bc095cbf1b674bb", + "width" : 200.0 + }, { + "height" : 64.0, + "url" : "https://i.scdn.co/image/0c30af5647c74fee14fb97981c23b336abbc9f21", + "width" : 64.0 + } ], + "name" : "Wanda Jackson", + "popularity" : 57.0, + "type" : "artist", + "uri" : "spotify:artist:5ZKMPRDHc7qElVJFh3uRqB" + }, { + "external_urls" : { + "spotify" : "https://open.spotify.com/artist/5hIClg6noTaCzMu2s5wp4f" + }, + "followers" : { + "href" : null, + "total" : 11703.0 + }, + "genres" : [ "rock-and-roll", "rockabilly" ], + "href" : "https://api.spotify.com/v1/artists/5hIClg6noTaCzMu2s5wp4f", + "id" : "5hIClg6noTaCzMu2s5wp4f", + "images" : [ { + "height" : 737.0, + "url" : "https://i.scdn.co/image/02b340629ddcc41fe48932fba641312f27de49a7", + "width" : 999.0 + }, { + "height" : 472.0, + "url" : "https://i.scdn.co/image/c99b5bc0bd9bfd566c6f64eccf9ae6426aaeff20", + "width" : 640.0 + }, { + "height" : 147.0, + "url" : "https://i.scdn.co/image/a2240effbf0c00539348d81e90380a14a51651cc", + "width" : 199.0 + }, { + "height" : 47.0, + "url" : "https://i.scdn.co/image/9af48c6576925720e3d43aacdd7797c52e1a639b", + "width" : 64.0 + } ], + "name" : "Carl Perkins", + "popularity" : 54.0, + "type" : "artist", + "uri" : "spotify:artist:5hIClg6noTaCzMu2s5wp4f" + }, { + "external_urls" : { + "spotify" : "https://open.spotify.com/artist/4xls23Ye9WR9yy3yYMpAMm" + }, + "followers" : { + "href" : null, + "total" : 44870.0 + }, + "genres" : [ "rock-and-roll", "rockabilly" ], + "href" : "https://api.spotify.com/v1/artists/4xls23Ye9WR9yy3yYMpAMm", + "id" : "4xls23Ye9WR9yy3yYMpAMm", + "images" : [ { + "height" : 1181.0, + "url" : "https://i.scdn.co/image/b4db13fb1d2e2872d7b7eac4b17d67870482f16f", + "width" : 1000.0 + }, { + "height" : 756.0, + "url" : "https://i.scdn.co/image/217387b531599ffb81751ab8629c4baf78d85c4e", + "width" : 640.0 + }, { + "height" : 236.0, + "url" : "https://i.scdn.co/image/82fe8f7a2d139b7c746b5ff6985f6b186113dd75", + "width" : 200.0 + }, { + "height" : 76.0, + "url" : "https://i.scdn.co/image/de0d8715aa69bdbbd1236c6c88528ff93804e86d", + "width" : 64.0 + } ], + "name" : "Little Richard", + "popularity" : 67.0, + "type" : "artist", + "uri" : "spotify:artist:4xls23Ye9WR9yy3yYMpAMm" + }, { + "external_urls" : { + "spotify" : "https://open.spotify.com/artist/73sSFVlM6pkweLXE8qw1OS" + }, + "followers" : { + "href" : null, + "total" : 21830.0 + }, + "genres" : [ "rock-and-roll", "rockabilly" ], + "href" : "https://api.spotify.com/v1/artists/73sSFVlM6pkweLXE8qw1OS", + "id" : "73sSFVlM6pkweLXE8qw1OS", + "images" : [ { + "height" : 1129.0, + "url" : "https://i.scdn.co/image/53b1e360f7e4978410529ee7a971c3f8a4118622", + "width" : 1000.0 + }, { + "height" : 723.0, + "url" : "https://i.scdn.co/image/e4eb935b9af1f78735e9e25e8e75e3685b81fdd8", + "width" : 640.0 + }, { + "height" : 226.0, + "url" : "https://i.scdn.co/image/d6f709471d825cb9cf991acb77b7fb87667c0de1", + "width" : 200.0 + }, { + "height" : 72.0, + "url" : "https://i.scdn.co/image/6ced7f8bcb6a04e22dd357c4110fa0e4349933cd", + "width" : 64.0 + } ], + "name" : "Ricky Nelson", + "popularity" : 58.0, + "type" : "artist", + "uri" : "spotify:artist:73sSFVlM6pkweLXE8qw1OS" + }, { + "external_urls" : { + "spotify" : "https://open.spotify.com/artist/1NAWG3AngjBXyKbmPaz92D" + }, + "followers" : { + "href" : null, + "total" : 21028.0 + }, + "genres" : [ "adult standards", "christmas", "lounge" ], + "href" : "https://api.spotify.com/v1/artists/1NAWG3AngjBXyKbmPaz92D", + "id" : "1NAWG3AngjBXyKbmPaz92D", + "images" : [ { + "height" : 1350.0, + "url" : "https://i.scdn.co/image/26444939b518af74c9674abad6442eb9e199906d", + "width" : 1000.0 + }, { + "height" : 864.0, + "url" : "https://i.scdn.co/image/5466fdb2473ddaa992904e4761d2fed45be46950", + "width" : 640.0 + }, { + "height" : 270.0, + "url" : "https://i.scdn.co/image/696a464da87ee2aeb931f86221444a0826604e7a", + "width" : 200.0 + }, { + "height" : 86.0, + "url" : "https://i.scdn.co/image/a8ba7a72d47d1961c471abac60a121751c17fb24", + "width" : 64.0 + } ], + "name" : "Sammy Davis Jr.", + "popularity" : 64.0, + "type" : "artist", + "uri" : "spotify:artist:1NAWG3AngjBXyKbmPaz92D" + }, { + "external_urls" : { + "spotify" : "https://open.spotify.com/artist/49e4v89VmlDcFCMyDv9wQ9" + }, + "followers" : { + "href" : null, + "total" : 147491.0 + }, + "genres" : [ "adult standards", "christmas", "lounge" ], + "href" : "https://api.spotify.com/v1/artists/49e4v89VmlDcFCMyDv9wQ9", + "id" : "49e4v89VmlDcFCMyDv9wQ9", + "images" : [ { + "height" : 1007.0, + "url" : "https://i.scdn.co/image/a655ecce75961bc7b43c07a5f8cb819c20cdaeaf", + "width" : 1000.0 + }, { + "height" : 645.0, + "url" : "https://i.scdn.co/image/0bac6bb37609824e6109931c7e7c9d87e7b42044", + "width" : 640.0 + }, { + "height" : 201.0, + "url" : "https://i.scdn.co/image/04f391d82e817fbf77fefc24d908078df52ca333", + "width" : 200.0 + }, { + "height" : 64.0, + "url" : "https://i.scdn.co/image/f7159bcb77e40d96eef52b58d0dc0065879ea789", + "width" : 64.0 + } ], + "name" : "Dean Martin", + "popularity" : 84.0, + "type" : "artist", + "uri" : "spotify:artist:49e4v89VmlDcFCMyDv9wQ9" + }, { + "external_urls" : { + "spotify" : "https://open.spotify.com/artist/09C0xjtosNAIXP36wTnWxd" + }, + "followers" : { + "href" : null, + "total" : 31771.0 + }, + "genres" : [ "new orleans blues", "rock-and-roll", "swamp pop" ], + "href" : "https://api.spotify.com/v1/artists/09C0xjtosNAIXP36wTnWxd", + "id" : "09C0xjtosNAIXP36wTnWxd", + "images" : [ { + "height" : 1170.0, + "url" : "https://i.scdn.co/image/1e7e3ddbe8c3862d32d35aef5e4a763718f1e370", + "width" : 1000.0 + }, { + "height" : 749.0, + "url" : "https://i.scdn.co/image/172221e04fef2e038871248b3abdecbcf8f5c131", + "width" : 640.0 + }, { + "height" : 234.0, + "url" : "https://i.scdn.co/image/5ee1c7e5f1a45125ee8315d90ca62e6afb04cc25", + "width" : 200.0 + }, { + "height" : 75.0, + "url" : "https://i.scdn.co/image/afe5d30d0286526a60aa0d37c02d5864eb24f67b", + "width" : 64.0 + } ], + "name" : "Fats Domino", + "popularity" : 67.0, + "type" : "artist", + "uri" : "spotify:artist:09C0xjtosNAIXP36wTnWxd" + }, { + "external_urls" : { + "spotify" : "https://open.spotify.com/artist/5VAHm7V5mnsxvQrWw3KHmx" + }, + "followers" : { + "href" : null, + "total" : 8685.0 + }, + "genres" : [ "rock-and-roll", "rockabilly" ], + "href" : "https://api.spotify.com/v1/artists/5VAHm7V5mnsxvQrWw3KHmx", + "id" : "5VAHm7V5mnsxvQrWw3KHmx", + "images" : [ { + "height" : 1224.0, + "url" : "https://i.scdn.co/image/f3f3a6df9ee1854a32a8a4e635820002c6ef32be", + "width" : 1000.0 + }, { + "height" : 784.0, + "url" : "https://i.scdn.co/image/4ebffb55a443fb401fe0233fd6c8bb42f381f235", + "width" : 640.0 + }, { + "height" : 245.0, + "url" : "https://i.scdn.co/image/12876b206cc3e3d1133a674c8e02caee88ca5285", + "width" : 200.0 + }, { + "height" : 78.0, + "url" : "https://i.scdn.co/image/4d3bf8fc93e3e0c7314c38142d38c74959c9f52d", + "width" : 64.0 + } ], + "name" : "Gene Vincent", + "popularity" : 52.0, + "type" : "artist", + "uri" : "spotify:artist:5VAHm7V5mnsxvQrWw3KHmx" + }, { + "external_urls" : { + "spotify" : "https://open.spotify.com/artist/1Mxqyy3pSjf8kZZL4QVxS0" + }, + "followers" : { + "href" : null, + "total" : 634417.0 + }, + "genres" : [ "adult standards", "christmas", "jazz christmas", "lounge" ], + "href" : "https://api.spotify.com/v1/artists/1Mxqyy3pSjf8kZZL4QVxS0", + "id" : "1Mxqyy3pSjf8kZZL4QVxS0", + "images" : [ { + "height" : 650.0, + "url" : "https://i.scdn.co/image/d0a3c1d046165b767e2924dd144882e2944d5dd9", + "width" : 999.0 + }, { + "height" : 416.0, + "url" : "https://i.scdn.co/image/d4da0d72899bb9267744e5f0c77c6560caac4fa9", + "width" : 640.0 + }, { + "height" : 130.0, + "url" : "https://i.scdn.co/image/8821d7a555d81884dca496f2c5d19ad906ce9289", + "width" : 200.0 + }, { + "height" : 42.0, + "url" : "https://i.scdn.co/image/6e842df4553e17b5cfb4d5bf490f17c77a45c138", + "width" : 64.0 + } ], + "name" : "Frank Sinatra", + "popularity" : 97.0, + "type" : "artist", + "uri" : "spotify:artist:1Mxqyy3pSjf8kZZL4QVxS0" + }, { + "external_urls" : { + "spotify" : "https://open.spotify.com/artist/1p0t3JtUTayV2wb1RGN9mO" + }, + "followers" : { + "href" : null, + "total" : 19965.0 + }, + "genres" : [ "rock-and-roll", "rockabilly" ], + "href" : "https://api.spotify.com/v1/artists/1p0t3JtUTayV2wb1RGN9mO", + "id" : "1p0t3JtUTayV2wb1RGN9mO", + "images" : [ { + "height" : 752.0, + "url" : "https://i.scdn.co/image/6c3d2f6c26991828bf2d776fc468b929ca31304a", + "width" : 648.0 + }, { + "height" : 743.0, + "url" : "https://i.scdn.co/image/21c81243f2df0b3ce5cdcd7af629beef7e8af76e", + "width" : 640.0 + }, { + "height" : 232.0, + "url" : "https://i.scdn.co/image/9a800b3323b9edcdb0267aad068aedd594cc1fd1", + "width" : 200.0 + }, { + "height" : 74.0, + "url" : "https://i.scdn.co/image/5b01110b8def5978979b9bd946612e353028828d", + "width" : 64.0 + } ], + "name" : "Eddie Cochran", + "popularity" : 59.0, + "type" : "artist", + "uri" : "spotify:artist:1p0t3JtUTayV2wb1RGN9mO" + }, { + "external_urls" : { + "spotify" : "https://open.spotify.com/artist/1eYhYunlNJlDoQhtYBvPsi" + }, + "followers" : { + "href" : null, + "total" : 233782.0 + }, + "genres" : [ "jazz blues", "jazz christmas", "soul blues" ], + "href" : "https://api.spotify.com/v1/artists/1eYhYunlNJlDoQhtYBvPsi", + "id" : "1eYhYunlNJlDoQhtYBvPsi", + "images" : [ { + "height" : 1239.0, + "url" : "https://i.scdn.co/image/7832094ca0d3539486b74f02924ba746c70b8951", + "width" : 1000.0 + }, { + "height" : 793.0, + "url" : "https://i.scdn.co/image/833f9840930f1e50b9583bd08267ab2bf47f17a9", + "width" : 640.0 + }, { + "height" : 248.0, + "url" : "https://i.scdn.co/image/bec5833f085cf25d49c8919a2396283c578e8751", + "width" : 200.0 + }, { + "height" : 79.0, + "url" : "https://i.scdn.co/image/86086d26f614a233fbeb4f1eda0a4b731bdb3766", + "width" : 64.0 + } ], + "name" : "Ray Charles", + "popularity" : 84.0, + "type" : "artist", + "uri" : "spotify:artist:1eYhYunlNJlDoQhtYBvPsi" + }, { + "external_urls" : { + "spotify" : "https://open.spotify.com/artist/3PrFCybHMqrcPls31JxoIl" + }, + "followers" : { + "href" : null, + "total" : 4194.0 + }, + "genres" : [ ], + "href" : "https://api.spotify.com/v1/artists/3PrFCybHMqrcPls31JxoIl", + "id" : "3PrFCybHMqrcPls31JxoIl", + "images" : [ { + "height" : 793.0, + "url" : "https://i.scdn.co/image/677e7852f650bb817d9783fa55e0d714fb459b9d", + "width" : 1000.0 + }, { + "height" : 508.0, + "url" : "https://i.scdn.co/image/f449d89e5c06d85409623cec058b5f52f1020ab1", + "width" : 640.0 + }, { + "height" : 159.0, + "url" : "https://i.scdn.co/image/0c8a4db99197186860f9c576f801f7228ba29aa8", + "width" : 200.0 + }, { + "height" : 51.0, + "url" : "https://i.scdn.co/image/5a77fe6826e7a3f0005233b620d0e25975be9af0", + "width" : 64.0 + } ], + "name" : "Johnny Burnette", + "popularity" : 43.0, + "type" : "artist", + "uri" : "spotify:artist:3PrFCybHMqrcPls31JxoIl" + }, { + "external_urls" : { + "spotify" : "https://open.spotify.com/artist/3MFp4cYuYtTZe3d3xkLLbr" + }, + "followers" : { + "href" : null, + "total" : 5595.0 + }, + "genres" : [ "rock-and-roll", "rockabilly" ], + "href" : "https://api.spotify.com/v1/artists/3MFp4cYuYtTZe3d3xkLLbr", + "id" : "3MFp4cYuYtTZe3d3xkLLbr", + "images" : [ { + "height" : 809.0, + "url" : "https://i.scdn.co/image/8e9c925577ff4d563f9f12324453be1b5d026494", + "width" : 1000.0 + }, { + "height" : 518.0, + "url" : "https://i.scdn.co/image/37b77aa15c67c4d8763a73301360d405715a7145", + "width" : 640.0 + }, { + "height" : 162.0, + "url" : "https://i.scdn.co/image/3b2ae8fdc389ee165b7f5787fd91ae6604ff4fca", + "width" : 200.0 + }, { + "height" : 52.0, + "url" : "https://i.scdn.co/image/fb39aac889247b6528b3bbc85c1e2ef773ad2b47", + "width" : 64.0 + } ], + "name" : "Bill Haley & His Comets", + "popularity" : 54.0, + "type" : "artist", + "uri" : "spotify:artist:3MFp4cYuYtTZe3d3xkLLbr" + }, { + "external_urls" : { + "spotify" : "https://open.spotify.com/artist/2gNK2HAaLVz5DZoD2moDQj" + }, + "followers" : { + "href" : null, + "total" : 1537.0 + }, + "genres" : [ "rock-and-roll", "rockabilly" ], + "href" : "https://api.spotify.com/v1/artists/2gNK2HAaLVz5DZoD2moDQj", + "id" : "2gNK2HAaLVz5DZoD2moDQj", + "images" : [ { + "height" : 1256.0, + "url" : "https://i.scdn.co/image/c0a8d6ba7404e6d4e4c91b9ccfd871f46d207379", + "width" : 1000.0 + }, { + "height" : 804.0, + "url" : "https://i.scdn.co/image/d2e1961c92cc63ac8f59a8a62623a86d170d02f3", + "width" : 640.0 + }, { + "height" : 251.0, + "url" : "https://i.scdn.co/image/1a6fdbc17f20312a8eae920165e57f12ef5ec2d4", + "width" : 200.0 + }, { + "height" : 80.0, + "url" : "https://i.scdn.co/image/933045fc20196da53541e477a17c1f443a97ef2c", + "width" : 64.0 + } ], + "name" : "The Big Bopper", + "popularity" : 39.0, + "type" : "artist", + "uri" : "spotify:artist:2gNK2HAaLVz5DZoD2moDQj" + }, { + "external_urls" : { + "spotify" : "https://open.spotify.com/artist/4cPHsZM98sKzmV26wlwD2W" + }, + "followers" : { + "href" : null, + "total" : 21188.0 + }, + "genres" : [ ], + "href" : "https://api.spotify.com/v1/artists/4cPHsZM98sKzmV26wlwD2W", + "id" : "4cPHsZM98sKzmV26wlwD2W", + "images" : [ { + "height" : 1469.0, + "url" : "https://i.scdn.co/image/b2d04f712c91bcf98a28ce1a8c2f674ddb724ec6", + "width" : 1000.0 + }, { + "height" : 940.0, + "url" : "https://i.scdn.co/image/4ca270764861f2e13851b8e5110bb96ba7f39359", + "width" : 640.0 + }, { + "height" : 294.0, + "url" : "https://i.scdn.co/image/89ecdb230bcc12e980ce58fd88d20cc6dbc5b388", + "width" : 200.0 + }, { + "height" : 94.0, + "url" : "https://i.scdn.co/image/2e615b79eb4c945b7a57e241448e681d7f2da8bd", + "width" : 64.0 + } ], + "name" : "Brenda Lee", + "popularity" : 70.0, + "type" : "artist", + "uri" : "spotify:artist:4cPHsZM98sKzmV26wlwD2W" + }, { + "external_urls" : { + "spotify" : "https://open.spotify.com/artist/6kACVPfCOnqzgfEF5ryl0x" + }, + "followers" : { + "href" : null, + "total" : 739238.0 + }, + "genres" : [ ], + "href" : "https://api.spotify.com/v1/artists/6kACVPfCOnqzgfEF5ryl0x", + "id" : "6kACVPfCOnqzgfEF5ryl0x", + "images" : [ { + "height" : 745.0, + "url" : "https://i.scdn.co/image/48284d2fdb793dc003f48a3eae3a86183c16501b", + "width" : 1000.0 + }, { + "height" : 477.0, + "url" : "https://i.scdn.co/image/cba6842c7bb9b42ba22bebce85213d6c090adb36", + "width" : 640.0 + }, { + "height" : 149.0, + "url" : "https://i.scdn.co/image/c397e657a14f79b7fc5d918ede6afba5698773e2", + "width" : 200.0 + }, { + "height" : 48.0, + "url" : "https://i.scdn.co/image/63e350b46a04447ea63400959d808360559da740", + "width" : 64.0 + } ], + "name" : "Johnny Cash", + "popularity" : 94.0, + "type" : "artist", + "uri" : "spotify:artist:6kACVPfCOnqzgfEF5ryl0x" + }, { + "external_urls" : { + "spotify" : "https://open.spotify.com/artist/6CXezToiGS8K6jr9kr8Muv" + }, + "followers" : { + "href" : null, + "total" : 1631.0 + }, + "genres" : [ ], + "href" : "https://api.spotify.com/v1/artists/6CXezToiGS8K6jr9kr8Muv", + "id" : "6CXezToiGS8K6jr9kr8Muv", + "images" : [ { + "height" : 640.0, + "url" : "https://i.scdn.co/image/9ff876b717e2abd9f7de4d6cdba124328acb0e26", + "width" : 640.0 + }, { + "height" : 300.0, + "url" : "https://i.scdn.co/image/3d59300a202f7513f22f467456ea5abce5ac1247", + "width" : 300.0 + }, { + "height" : 64.0, + "url" : "https://i.scdn.co/image/ee70c0a4193f80c8d749c1b9ee3af302f52da991", + "width" : 64.0 + } ], + "name" : "The Jordanaires", + "popularity" : 57.0, + "type" : "artist", + "uri" : "spotify:artist:6CXezToiGS8K6jr9kr8Muv" + }, { + "external_urls" : { + "spotify" : "https://open.spotify.com/artist/293zczrfYafIItmnmM3coR" + }, + "followers" : { + "href" : null, + "total" : 109722.0 + }, + "genres" : [ "rock-and-roll", "rockabilly" ], + "href" : "https://api.spotify.com/v1/artists/293zczrfYafIItmnmM3coR", + "id" : "293zczrfYafIItmnmM3coR", + "images" : [ { + "height" : 1198.0, + "url" : "https://i.scdn.co/image/806ae8389df74bb2f8df1adf64c67c0e6dc76048", + "width" : 1000.0 + }, { + "height" : 766.0, + "url" : "https://i.scdn.co/image/f07a0dc93bde1aa294355c26b2a75edaa274c8f8", + "width" : 640.0 + }, { + "height" : 240.0, + "url" : "https://i.scdn.co/image/c5d23d159328aa908baaeeff6fa4855cf8519999", + "width" : 200.0 + }, { + "height" : 77.0, + "url" : "https://i.scdn.co/image/98006c221cbcc29bc9746757e69fa896fd0a5640", + "width" : 64.0 + } ], + "name" : "Chuck Berry", + "popularity" : 74.0, + "type" : "artist", + "uri" : "spotify:artist:293zczrfYafIItmnmM3coR" + }, { + "external_urls" : { + "spotify" : "https://open.spotify.com/artist/0JDkhL4rjiPNEp92jAgJnS" + }, + "followers" : { + "href" : null, + "total" : 95801.0 + }, + "genres" : [ "brill building pop", "rock-and-roll", "rockabilly" ], + "href" : "https://api.spotify.com/v1/artists/0JDkhL4rjiPNEp92jAgJnS", + "id" : "0JDkhL4rjiPNEp92jAgJnS", + "images" : [ { + "height" : 1375.0, + "url" : "https://i.scdn.co/image/da71623df844c01e6af2a6e770f3873950264183", + "width" : 1000.0 + }, { + "height" : 880.0, + "url" : "https://i.scdn.co/image/8d084d83df7b70b909a0a5c9fd797eb6c4ce6f23", + "width" : 640.0 + }, { + "height" : 275.0, + "url" : "https://i.scdn.co/image/f819fd632518ed76337a76d6b5b26fe77abbe8ec", + "width" : 200.0 + }, { + "height" : 88.0, + "url" : "https://i.scdn.co/image/b0cfbd6573f3402378d004a5afa0ac4ac629e808", + "width" : 64.0 + } ], + "name" : "Roy Orbison", + "popularity" : 73.0, + "type" : "artist", + "uri" : "spotify:artist:0JDkhL4rjiPNEp92jAgJnS" + } ] +} diff --git a/track.go b/track.go index b265ad2..45b9e70 100644 --- a/track.go +++ b/track.go @@ -16,15 +16,15 @@ type TrackExternalIDs struct { // SimpleTrack contains basic info about a track. type SimpleTrack struct { - Album SimpleAlbum `json:"album"` + Album SimpleAlbum `json:"album"` Artists []SimpleArtist `json:"artists"` // A list of the countries in which the track can be played, // identified by their ISO 3166-1 alpha-2 codes. AvailableMarkets []string `json:"available_markets"` // The disc number (usually 1 unless the album consists of more than one disc). - DiscNumber int `json:"disc_number"` + DiscNumber Numeric `json:"disc_number"` // The length of the track, in milliseconds. - Duration int `json:"duration_ms"` + Duration Numeric `json:"duration_ms"` // Whether or not the track has explicit lyrics. // true => yes, it does; false => no, it does not. Explicit bool `json:"explicit"` @@ -41,8 +41,8 @@ type SimpleTrack struct { // The number of the track. If an album has several // discs, the track number is the number on the specified // DiscNumber. - TrackNumber int `json:"track_number"` - URI URI `json:"uri"` + TrackNumber Numeric `json:"track_number"` + URI URI `json:"uri"` // Type of the track Type string `json:"type"` } @@ -80,7 +80,7 @@ type FullTrack struct { // Popularity of the track. The value will be between 0 and 100, // with 100 being the most popular. The popularity is calculated from // both total plays and most recent plays. - Popularity int `json:"popularity"` + Popularity Numeric `json:"popularity"` // IsPlayable defines if the track is playable. It's reported when the "market" parameter is passed to the tracks // listing API. diff --git a/track_test.go b/track_test.go index f45a07d..6ef489b 100644 --- a/track_test.go +++ b/track_test.go @@ -20,6 +20,20 @@ func TestFindTrack(t *testing.T) { } } +func TestFindTrackWithFloats(t *testing.T) { + client, server := testClientFile(http.StatusOK, "test_data/find_track_with_floats.txt") + defer server.Close() + + track, err := client.GetTrack(context.Background(), "1zHlj4dQ8ZAtrayhuDDmkY") + if err != nil { + t.Error(err) + return + } + if track.Name != "Timber" { + t.Errorf("Wanted track Timer, got %s\n", track.Name) + } +} + func TestFindTracksSimple(t *testing.T) { client, server := testClientFile(http.StatusOK, "test_data/find_tracks_simple.txt") defer server.Close() diff --git a/user_test.go b/user_test.go index 6b40b9f..acc1eb5 100644 --- a/user_test.go +++ b/user_test.go @@ -209,7 +209,7 @@ func TestCurrentUsersTracks(t *testing.T) { t.Errorf("Expect 3 results, got %d\n", tracks.Total) return } - if len(tracks.Tracks) != tracks.Total { + if len(tracks.Tracks) != int(tracks.Total) { t.Error("Didn't get expected number of results") return } @@ -239,7 +239,7 @@ func TestCurrentUsersAlbums(t *testing.T) { t.Errorf("Expect 2 results, got %d\n", albums.Total) return } - if len(albums.Albums) != albums.Total { + if len(albums.Albums) != int(albums.Total) { t.Error("Didn't get expected number of results") return } @@ -281,7 +281,7 @@ func TestCurrentUsersPlaylists(t *testing.T) { Name string Description string Public bool - TrackCount uint + TrackCount int }{ {"Core", "", true, 3}, {"Black/Atmo/Prog ?", "This is kinda fuzzy", true, 10}, @@ -300,7 +300,7 @@ func TestCurrentUsersPlaylists(t *testing.T) { if p.IsPublic != tests[i].Public { t.Errorf("Expected public to be %#v, got %#v\n", tests[i].Public, p.IsPublic) } - if p.Tracks.Total != tests[i].TrackCount { + if int(p.Tracks.Total) != tests[i].TrackCount { t.Errorf("Expected %d tracks, got %d\n", tests[i].TrackCount, p.Tracks.Total) } } @@ -356,7 +356,7 @@ func TestUsersFollowedArtists(t *testing.T) { t.Fatal(err) } exp := 20 - if artists.Limit != exp { + if int(artists.Limit) != exp { t.Errorf("Expected limit %d, got %d\n", exp, artists.Limit) } if a := artists.Cursor.After; a != "0aV6DOiouImYTqrR5YlIqx" { @@ -402,7 +402,7 @@ func TestCurrentUsersTopArtists(t *testing.T) { t.Errorf("Expected total 10, got %d\n", artists.Total) return } - if len(artists.Artists) != artists.Total { + if len(artists.Artists) != int(artists.Total) { t.Error("Didn't get expected number of results") return } @@ -435,7 +435,7 @@ func TestCurrentUsersTopTracks(t *testing.T) { t.Errorf("Expected total 380, got %d\n", tracks.Total) return } - if len(tracks.Tracks) != tracks.Limit { + if len(tracks.Tracks) != int(tracks.Limit) { t.Errorf("Didn't get expected number of results") return }