use write macro in meta item preview deserializing test
use crate::types::resource::{MetaItemBehaviorHints, MetaItemPreview, PosterShape};
use chrono::prelude::TimeZone;
use chrono::Utc;
+use std::fmt::Write;
#[test]
fn deserialize_meta_item_preview() {
@@ -52,9 +53,12 @@ fn deserialize_meta_item_preview() {
behavior_hints: MetaItemBehaviorHints::default(),
},
];
- let meta_item_previews_json = r#"
+ let mut meta_item_previews_json = "".to_string();
+ write!(
+ meta_item_previews_json,
+ r#"
[
- {
+ {{
"id": "id1",
"type": "type_name",
"name": "name",
@@ -66,13 +70,9 @@ fn deserialize_meta_item_preview() {
"released": "2020-01-01T00:00:00Z",
"posterShape": "square",
"trailerStreams": [],
- "behaviorHints": {
- "defaultVideoId": null,
- "featuredVideoId": null,
- "hasScheduledVideos": false
- }
- },
- {
+ "behaviorHints": {}
+ }},
+ {{
"id": "id2",
"type": "type_name",
"poster": null,
@@ -81,8 +81,8 @@ fn deserialize_meta_item_preview() {
"releaseInfo": null,
"runtime": null,
"released": null
- },
- {
+ }},
+ {{
"id": "id3",
"type": "type_name",
"name": "name",
@@ -94,14 +94,14 @@ fn deserialize_meta_item_preview() {
"released": null,
"posterShape": "invalid",
"trailerStreams": [],
- "behaviorHints": {
- "defaultVideoId": null,
- "featuredVideoId": null,
- "hasScheduledVideos": false
- }
- }
+ "behaviorHints": {}
+ }}
]
- "#;
+ "#,
+ serde_json::to_string(&MetaItemBehaviorHints::default()).unwrap(),
+ serde_json::to_string(&MetaItemBehaviorHints::default()).unwrap()
+ )
+ .unwrap();
let meta_item_previews_deserialize: Vec<MetaItemPreview> =
serde_json::from_str(&meta_item_previews_json).unwrap();
assert_eq!(
