// Include tests generated by `build.rs` mod lookup { include!(concat!(env!("OUT_DIR"), "/lookup.rs")); } mod browse { include!(concat!(env!("OUT_DIR"), "/browse.rs")); } mod search { include!(concat!(env!("OUT_DIR"), "/search.rs")); } mod entity { #[test] fn test_recording_fields() { use musicbrainz_rs_nova::entity::recording::Recording; let recording: Recording = serde_json::from_str(include_str!( "data/lookup/recording/b9ad642e-b012-41c7-b72a-42cf4911f9ff.json" )) .unwrap(); assert!(recording.artist_credit.is_some_and(|x| x.len() == 2)); assert_eq!(recording.isrcs, Some(vec!("JPB600760301".to_string()))); assert_eq!(recording.title, "LAST ANGEL".to_string()); assert_eq!(recording.video, Some(false)); assert!(recording.releases.is_some_and(|x| x.len() == 15)); assert_eq!(recording.disambiguation, Some("".to_string())); assert_eq!( recording.first_release_date, Some(chrono::NaiveDate::from_ymd_opt(2007, 11, 7).unwrap()) ); assert_eq!( recording.id, "b9ad642e-b012-41c7-b72a-42cf4911f9ff".to_string() ); assert_eq!(recording.length, Some(230240)); } #[test] fn test_release_fields() { use musicbrainz_rs_nova::entity::release::*; let release: Release = serde_json::from_str(include_str!( "data/lookup/release//b1dc9838-adf3-43f2-93f9-802b46e5fe59.json" )) .unwrap(); assert!(release.label_info.is_some_and(|x| x.len() == 1)); assert_eq!( release.text_representation, Some(ReleaseTextRepresentation { script: Some(ReleaseScript::Latn), language: Some(Language::Eng), }) ); // TODO: Add support for collections field. // See . assert_eq!( release.id, "b1dc9838-adf3-43f2-93f9-802b46e5fe59".to_string() ); assert_eq!(release.asin, Some("B00005NEKI".to_string())); assert!(release.aliases.is_some_and(|x| x.len() == 1)); assert!(release.artist_credit.is_some_and(|x| x.len() == 1)); // TODO: Add support for cover-art-archive field. // See . assert_eq!( release.status_id, Some("4e304316-386d-3409-af2e-78857eec5cfe".to_string()) ); assert!(release.genres.is_some_and(|x| x.is_empty())); assert_eq!(release.status, Some(ReleaseStatus::Official)); assert!(release.relations.is_some_and(|x| x.len() == 1)); assert_eq!( release.packaging_id, Some("ec27701a-4a22-37f4-bfac-6616e0f9750a".to_string()) ); assert!(release.media.is_some_and(|x| x.len() == 1)); assert_eq!(release.quality, Some(ReleaseQuality::Normal)); assert!(release.tags.is_some_and(|x| x.is_empty())); assert_eq!(release.barcode, Some("08464670532".to_string())); assert!(release.release_group.is_some()); assert_eq!(release.title, "A Hot Summer Night in ’59".to_string()); assert_eq!(release.annotation, None); } }