api complete coverage
This commit is contained in:
parent
369b4ecf98
commit
2b72726428
49
src/external/musicbrainz/api/lookup.rs
vendored
49
src/external/musicbrainz/api/lookup.rs
vendored
@ -162,19 +162,9 @@ mod tests {
|
|||||||
release_groups: Some(vec![de_release_group.clone()]),
|
release_groups: Some(vec![de_release_group.clone()]),
|
||||||
};
|
};
|
||||||
|
|
||||||
let release_group = MbReleaseGroupMeta {
|
|
||||||
id: de_release_group.id.0,
|
|
||||||
title: de_release_group.title.into(),
|
|
||||||
first_release_date: de_release_group.first_release_date.0,
|
|
||||||
primary_type: de_release_group.primary_type.0,
|
|
||||||
secondary_types: de_release_group
|
|
||||||
.secondary_types
|
|
||||||
.as_ref()
|
|
||||||
.map(|v| v.into_iter().map(|st| st.0).collect()),
|
|
||||||
};
|
|
||||||
let response = LookupArtistResponse {
|
let response = LookupArtistResponse {
|
||||||
meta: de_meta.into(),
|
meta: de_meta.into(),
|
||||||
release_groups: vec![release_group],
|
release_groups: vec![de_release_group.into()],
|
||||||
};
|
};
|
||||||
|
|
||||||
http.expect_get()
|
http.expect_get()
|
||||||
@ -191,4 +181,41 @@ mod tests {
|
|||||||
|
|
||||||
assert_eq!(result, response);
|
assert_eq!(result, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn lookup_release_group() {
|
||||||
|
let mbid = "00000000-0000-0000-0000-000000000000";
|
||||||
|
let mut http = MockIMusicBrainzHttp::new();
|
||||||
|
let url = format!("https://musicbrainz.org/ws/2/release-group/{mbid}",);
|
||||||
|
|
||||||
|
let de_meta = SerdeMbReleaseGroupMeta {
|
||||||
|
id: SerdeMbid("11111111-1111-1111-1111-111111111111".try_into().unwrap()),
|
||||||
|
title: String::from("an album"),
|
||||||
|
first_release_date: SerdeAlbumDate((1986, 4).into()),
|
||||||
|
primary_type: SerdeAlbumPrimaryType(AlbumPrimaryType::Album),
|
||||||
|
secondary_types: Some(vec![SerdeAlbumSecondaryType(
|
||||||
|
AlbumSecondaryType::Compilation,
|
||||||
|
)]),
|
||||||
|
};
|
||||||
|
let de_response = DeserializeLookupReleaseGroupResponse {
|
||||||
|
meta: de_meta.clone(),
|
||||||
|
};
|
||||||
|
|
||||||
|
let response = LookupReleaseGroupResponse {
|
||||||
|
meta: de_meta.into(),
|
||||||
|
};
|
||||||
|
|
||||||
|
http.expect_get()
|
||||||
|
.times(1)
|
||||||
|
.with(predicate::eq(url))
|
||||||
|
.return_once(|_| Ok(de_response));
|
||||||
|
|
||||||
|
let mut client = MusicBrainzClient::new(http);
|
||||||
|
|
||||||
|
let mbid: Mbid = "00000000-0000-0000-0000-000000000000".try_into().unwrap();
|
||||||
|
let request = LookupReleaseGroupRequest::new(&mbid);
|
||||||
|
let result = client.lookup_release_group(request).unwrap();
|
||||||
|
|
||||||
|
assert_eq!(result, response);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user