musichoard/src/tests.rs

464 lines
19 KiB
Rust
Raw Normal View History

macro_rules! library_collection {
() => {
vec![
Artist {
id: ArtistId {
name: "Album_Artist A".to_string(),
},
sort: None,
musicbrainz: None,
properties: HashMap::new(),
albums: vec![
Album {
id: AlbumId {
year: 1998,
title: "album_title a.a".to_string(),
},
tracks: vec![
Track {
id: TrackId {
number: 1,
title: "track a.a.1".to_string(),
},
artist: vec!["artist a.a.1".to_string()],
quality: Quality {
format: Format::Flac,
bitrate: 992,
},
},
Track {
id: TrackId {
number: 2,
title: "track a.a.2".to_string(),
},
artist: vec![
"artist a.a.2.1".to_string(),
"artist a.a.2.2".to_string(),
],
quality: Quality {
format: Format::Mp3,
bitrate: 320,
},
},
Track {
id: TrackId {
number: 3,
title: "track a.a.3".to_string(),
},
artist: vec!["artist a.a.3".to_string()],
quality: Quality {
format: Format::Flac,
bitrate: 1061,
},
},
Track {
id: TrackId {
number: 4,
title: "track a.a.4".to_string(),
},
artist: vec!["artist a.a.4".to_string()],
quality: Quality {
format: Format::Flac,
bitrate: 1042,
},
},
],
},
Album {
id: AlbumId {
year: 2015,
title: "album_title a.b".to_string(),
},
tracks: vec![
Track {
id: TrackId {
number: 1,
title: "track a.b.1".to_string(),
},
artist: vec!["artist a.b.1".to_string()],
quality: Quality {
format: Format::Flac,
bitrate: 1004,
},
},
Track {
id: TrackId {
number: 2,
title: "track a.b.2".to_string(),
},
artist: vec!["artist a.b.2".to_string()],
quality: Quality {
format: Format::Flac,
bitrate: 1077,
},
},
],
},
],
},
Artist {
id: ArtistId {
name: "Album_Artist B".to_string(),
},
sort: None,
musicbrainz: None,
properties: HashMap::new(),
albums: vec![
Album {
id: AlbumId {
year: 2003,
title: "album_title b.a".to_string(),
},
tracks: vec![
Track {
id: TrackId {
number: 1,
title: "track b.a.1".to_string(),
},
artist: vec!["artist b.a.1".to_string()],
quality: Quality {
format: Format::Mp3,
bitrate: 190,
},
},
Track {
id: TrackId {
number: 2,
title: "track b.a.2".to_string(),
},
artist: vec![
"artist b.a.2.1".to_string(),
"artist b.a.2.2".to_string(),
],
quality: Quality {
format: Format::Mp3,
bitrate: 120,
},
},
],
},
Album {
id: AlbumId {
year: 2008,
title: "album_title b.b".to_string(),
},
tracks: vec![
Track {
id: TrackId {
number: 1,
title: "track b.b.1".to_string(),
},
artist: vec!["artist b.b.1".to_string()],
quality: Quality {
format: Format::Flac,
bitrate: 1077,
},
},
Track {
id: TrackId {
number: 2,
title: "track b.b.2".to_string(),
},
artist: vec![
"artist b.b.2.1".to_string(),
"artist b.b.2.2".to_string(),
],
quality: Quality {
format: Format::Mp3,
bitrate: 320,
},
},
],
},
Album {
id: AlbumId {
year: 2009,
title: "album_title b.c".to_string(),
},
tracks: vec![
Track {
id: TrackId {
number: 1,
title: "track b.c.1".to_string(),
},
artist: vec!["artist b.c.1".to_string()],
quality: Quality {
format: Format::Mp3,
bitrate: 190,
},
},
Track {
id: TrackId {
number: 2,
title: "track b.c.2".to_string(),
},
artist: vec![
"artist b.c.2.1".to_string(),
"artist b.c.2.2".to_string(),
],
quality: Quality {
format: Format::Mp3,
bitrate: 120,
},
},
],
},
Album {
id: AlbumId {
year: 2015,
title: "album_title b.d".to_string(),
},
tracks: vec![
Track {
id: TrackId {
number: 1,
title: "track b.d.1".to_string(),
},
artist: vec!["artist b.d.1".to_string()],
quality: Quality {
format: Format::Mp3,
bitrate: 190,
},
},
Track {
id: TrackId {
number: 2,
title: "track b.d.2".to_string(),
},
artist: vec![
"artist b.d.2.1".to_string(),
"artist b.d.2.2".to_string(),
],
quality: Quality {
format: Format::Mp3,
bitrate: 120,
},
},
],
},
],
},
Artist {
id: ArtistId {
name: "The Album_Artist C".to_string(),
},
sort: Some(ArtistId {
name: "Album_Artist C, The".to_string(),
}),
musicbrainz: None,
properties: HashMap::new(),
albums: vec![
Album {
id: AlbumId {
year: 1985,
title: "album_title c.a".to_string(),
},
tracks: vec![
Track {
id: TrackId {
number: 1,
title: "track c.a.1".to_string(),
},
artist: vec!["artist c.a.1".to_string()],
quality: Quality {
format: Format::Mp3,
bitrate: 320,
},
},
Track {
id: TrackId {
number: 2,
title: "track c.a.2".to_string(),
},
artist: vec![
"artist c.a.2.1".to_string(),
"artist c.a.2.2".to_string(),
],
quality: Quality {
format: Format::Mp3,
bitrate: 120,
},
},
],
},
Album {
id: AlbumId {
year: 2018,
title: "album_title c.b".to_string(),
},
tracks: vec![
Track {
id: TrackId {
number: 1,
title: "track c.b.1".to_string(),
},
artist: vec!["artist c.b.1".to_string()],
quality: Quality {
format: Format::Flac,
bitrate: 1041,
},
},
Track {
id: TrackId {
number: 2,
title: "track c.b.2".to_string(),
},
artist: vec![
"artist c.b.2.1".to_string(),
"artist c.b.2.2".to_string(),
],
quality: Quality {
format: Format::Flac,
bitrate: 756,
},
},
],
},
],
},
Artist {
id: ArtistId {
name: "Album_Artist D".to_string(),
},
sort: None,
musicbrainz: None,
properties: HashMap::new(),
albums: vec![
Album {
id: AlbumId {
year: 1995,
title: "album_title d.a".to_string(),
},
tracks: vec![
Track {
id: TrackId {
number: 1,
title: "track d.a.1".to_string(),
},
artist: vec!["artist d.a.1".to_string()],
quality: Quality {
format: Format::Mp3,
bitrate: 120,
},
},
Track {
id: TrackId {
number: 2,
title: "track d.a.2".to_string(),
},
artist: vec![
"artist d.a.2.1".to_string(),
"artist d.a.2.2".to_string(),
],
quality: Quality {
format: Format::Mp3,
bitrate: 120,
},
},
],
},
Album {
id: AlbumId {
year: 2028,
title: "album_title d.b".to_string(),
},
tracks: vec![
Track {
id: TrackId {
number: 1,
title: "track d.b.1".to_string(),
},
artist: vec!["artist d.b.1".to_string()],
quality: Quality {
format: Format::Flac,
bitrate: 841,
},
},
Track {
id: TrackId {
number: 2,
title: "track d.b.2".to_string(),
},
artist: vec![
"artist d.b.2.1".to_string(),
"artist d.b.2.2".to_string(),
],
quality: Quality {
format: Format::Flac,
bitrate: 756,
},
},
],
},
],
},
]
};
}
macro_rules! full_collection {
() => {{
let mut collection = library_collection!();
let mut iter = collection.iter_mut();
let artist_a = iter.next().unwrap();
assert_eq!(artist_a.id.name, "Album_Artist A");
artist_a.musicbrainz = Some(
MusicBrainz::new(
"https://musicbrainz.org/artist/00000000-0000-0000-0000-000000000000",
)
.unwrap(),
);
artist_a.properties = HashMap::from([
(String::from("MusicButler"), vec![
String::from("https://www.musicbutler.io/artist-page/000000000"),
]),
(String::from("Qobuz"), vec![
String::from(
"https://www.qobuz.com/nl-nl/interpreter/artist-a/download-streaming-albums",
)
]),
]);
let artist_b = iter.next().unwrap();
assert_eq!(artist_b.id.name, "Album_Artist B");
artist_b.musicbrainz = Some(
MusicBrainz::new(
"https://musicbrainz.org/artist/11111111-1111-1111-1111-111111111111",
).unwrap(),
);
artist_b.properties = HashMap::from([
(String::from("MusicButler"), vec![
String::from("https://www.musicbutler.io/artist-page/111111111"),
String::from("https://www.musicbutler.io/artist-page/111111112"),
]),
(String::from("Bandcamp"), vec![String::from("https://artist-b.bandcamp.com/")]),
(String::from("Qobuz"), vec![
String::from(
"https://www.qobuz.com/nl-nl/interpreter/artist-b/download-streaming-albums",
)
]),
]);
let artist_c = iter.next().unwrap();
assert_eq!(artist_c.id.name, "The Album_Artist C");
artist_c.musicbrainz = Some(
MusicBrainz::new(
"https://musicbrainz.org/artist/11111111-1111-1111-1111-111111111111",
).unwrap(),
);
// Nothing for artist_d
collection
}};
}
pub(crate) use full_collection;
pub(crate) use library_collection;