musichoard/src/tests.rs

327 lines
13 KiB
Rust
Raw Normal View History

macro_rules! library_collection {
() => {
vec![
Artist {
id: ArtistId {
name: "album_artist a".to_string(),
},
sort: None,
properties: ArtistProperties {
musicbrainz: None,
musicbutler: vec![],
bandcamp: vec![],
qobuz: None,
},
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,
},
},
],
},
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,
properties: ArtistProperties {
musicbrainz: None,
musicbutler: vec![],
bandcamp: vec![],
qobuz: None,
},
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,
},
},
],
},
],
},
Artist {
id: ArtistId {
name: "album_artist c".to_string(),
},
sort: None,
properties: ArtistProperties {
musicbrainz: None,
musicbutler: vec![],
bandcamp: vec![],
qobuz: None,
},
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,
},
},
],
},
],
},
]
};
}
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.properties = ArtistProperties {
musicbrainz: Some(
MusicBrainz::new(
"https://musicbrainz.org/artist/00000000-0000-0000-0000-000000000000",
)
.unwrap(),
),
musicbutler: vec![
MusicButler::new("https://www.musicbutler.io/artist-page/000000000").unwrap(),
],
bandcamp: vec![],
qobuz: Some(
Qobuz::new(
"https://www.qobuz.com/nl-nl/interpreter/artist-a/download-streaming-albums",
)
.unwrap(),
),
};
let artist_b = iter.next().unwrap();
assert_eq!(artist_b.id.name, "album_artist b");
artist_b.properties = ArtistProperties {
musicbrainz: Some(
MusicBrainz::new(
"https://musicbrainz.org/artist/11111111-1111-1111-1111-111111111111",
)
.unwrap(),
),
musicbutler: vec![
MusicButler::new("https://www.musicbutler.io/artist-page/111111111").unwrap(),
MusicButler::new("https://www.musicbutler.io/artist-page/111111112").unwrap(),
],
bandcamp: vec![Bandcamp::new("https://artist-b.bandcamp.com/").unwrap()],
qobuz: Some(
Qobuz::new(
"https://www.qobuz.com/nl-nl/interpreter/artist-b/download-streaming-albums",
)
.unwrap(),
),
};
let artist_c = iter.next().unwrap();
assert_eq!(artist_c.id.name, "album_artist c");
artist_c.properties = ArtistProperties {
musicbrainz: Some(
MusicBrainz::new(
"https://musicbrainz.org/artist/11111111-1111-1111-1111-111111111111",
)
.unwrap(),
),
musicbutler: vec![],
bandcamp: vec![],
qobuz: None,
};
collection
}};
}
pub(crate) use full_collection;
pub(crate) use library_collection;