Skip to content

Commit

Permalink
fix: it compiles
Browse files Browse the repository at this point in the history
  • Loading branch information
merisbahti authored and marioortizmanero committed May 25, 2022
1 parent 97c4adf commit 1fce826
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
2 changes: 2 additions & 0 deletions rspotify-model/src/idtypes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -471,12 +471,14 @@ impl Id for UserId {
define_impls!(ArtistId, AlbumId, TrackId, PlaylistId, UserId, ShowId, EpisodeId);

// Grouping up the IDs into more specific traits
#[derive(Clone)]
pub enum PlayContext {
Artist(ArtistId),
Album(AlbumId),
Playlist(PlaylistId),
Show(ShowId),
}
#[derive(Clone)]
pub enum Playable {
Track(TrackId),
Episode(EpisodeId),
Expand Down
32 changes: 19 additions & 13 deletions tests/test_with_oauth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,10 @@ async fn test_new_releases_with_from_token() {
#[ignore]
async fn test_playback() {
let client = oauth_client().await;
let uris: [&dyn PlayableId; 3] = [
&TrackId::from_uri("spotify:track:4iV5W9uYEdYUVa79Axb7Rh").unwrap(),
&TrackId::from_uri("spotify:track:2DzSjFQKetFhkFCuDWhioi").unwrap(),
&EpisodeId::from_id("0lbiy3LKzIY2fnyjioC11p").unwrap(),
let uris = [
Playable::Track(TrackId::from_uri("spotify:track:4iV5W9uYEdYUVa79Axb7Rh").unwrap()),
Playable::Track(TrackId::from_uri("spotify:track:2DzSjFQKetFhkFCuDWhioi").unwrap()),
Playable::Episode(EpisodeId::from_id("0lbiy3LKzIY2fnyjioC11p").unwrap()),
];
let devices = client.device().await.unwrap();

Expand All @@ -346,7 +346,12 @@ async fn test_playback() {

// Starting playback of some songs
client
.start_uris_playback(uris, Some(device_id), Some(Offset::for_position(0)), None)
.start_uris_playback(
uris.to_vec(),
Some(device_id),
Some(Offset::for_position(0)),
None,
)
.await
.unwrap();

Expand Down Expand Up @@ -638,7 +643,7 @@ async fn check_num_tracks(client: &AuthCodeSpotify, playlist_id: &PlaylistId, nu
#[maybe_async]
async fn check_playlist_tracks(client: &AuthCodeSpotify, playlist: &FullPlaylist) {
// The tracks in the playlist, some of them repeated
let tracks = vec![
let tracks = [
Playable::Track(TrackId::from_uri("spotify:track:5iKndSu1XI74U2OZePzP8L").unwrap()),
Playable::Track(TrackId::from_uri("spotify:track:5iKndSu1XI74U2OZePzP8L").unwrap()),
Playable::Episode(EpisodeId::from_uri("spotify/episode/381XrGKkcdNkLwfsQ4Mh5y").unwrap()),
Expand All @@ -647,7 +652,7 @@ async fn check_playlist_tracks(client: &AuthCodeSpotify, playlist: &FullPlaylist

// Firstly adding some tracks
client
.playlist_add_items(&playlist.id, tracks, None)
.playlist_add_items(&playlist.id, tracks.to_vec(), None)
.await
.unwrap();
check_num_tracks(client, &playlist.id, tracks.len() as i32).await;
Expand All @@ -661,7 +666,7 @@ async fn check_playlist_tracks(client: &AuthCodeSpotify, playlist: &FullPlaylist
check_num_tracks(client, &playlist.id, tracks.len() as i32).await;

// Replacing the tracks
let replaced_tracks = vec![
let replaced_tracks = [
Playable::Track(TrackId::from_uri("spotify:track:4iV5W9uYEdYUVa79Axb7Rh").unwrap()),
Playable::Track(TrackId::from_uri("spotify:track:4iV5W9uYEdYUVa79Axb7Rh").unwrap()),
Playable::Track(TrackId::from_uri("spotify:track:1301WleyT98MSxVHPZCA6M").unwrap()),
Expand All @@ -671,7 +676,7 @@ async fn check_playlist_tracks(client: &AuthCodeSpotify, playlist: &FullPlaylist
Playable::Track(TrackId::from_uri("spotify:track:5m2en2ndANCPembKOYr1xL").unwrap()),
];
client
.playlist_replace_items(&playlist.id, replaced_tracks)
.playlist_replace_items(&playlist.id, replaced_tracks.to_vec())
.await
.unwrap();
// Making sure the number of tracks is updated
Expand All @@ -680,11 +685,11 @@ async fn check_playlist_tracks(client: &AuthCodeSpotify, playlist: &FullPlaylist
// Removes a few specific tracks
let tracks = [
ItemPositions {
id: &TrackId::from_uri("spotify:track:4iV5W9uYEdYUVa79Axb7Rh").unwrap(),
id: Playable::Track(TrackId::from_uri("spotify:track:4iV5W9uYEdYUVa79Axb7Rh").unwrap()),
positions: &[0],
},
ItemPositions {
id: &TrackId::from_uri("spotify:track:5m2en2ndANCPembKOYr1xL").unwrap(),
id: Playable::Track(TrackId::from_uri("spotify:track:5m2en2ndANCPembKOYr1xL").unwrap()),
positions: &[4, 6],
},
];
Expand All @@ -696,7 +701,7 @@ async fn check_playlist_tracks(client: &AuthCodeSpotify, playlist: &FullPlaylist
check_num_tracks(client, &playlist.id, replaced_tracks.len() as i32 - 3).await;

// Removes all occurrences of two tracks
let to_remove: Vec![PlayableId] = [
let to_remove = vec![
Playable::Track(TrackId::from_uri("spotify:track:4iV5W9uYEdYUVa79Axb7Rh").unwrap()),
Playable::Episode(EpisodeId::from_id("0lbiy3LKzIY2fnyjioC11p").unwrap()),
];
Expand Down Expand Up @@ -763,7 +768,8 @@ async fn test_volume() {
async fn test_add_queue() {
// NOTE: unfortunately it's impossible to revert this test

let birdy_uri = TrackId::from_uri("spotify:track:6rqhFgbbKwnb9MLmUQDhG6").unwrap();
let birdy_uri =
Playable::Track(TrackId::from_uri("spotify:track:6rqhFgbbKwnb9MLmUQDhG6").unwrap());
oauth_client()
.await
.add_item_to_queue(&birdy_uri, None)
Expand Down

0 comments on commit 1fce826

Please sign in to comment.