use write macro in meta item deserializing test
use crate::types::resource::{MetaItem, MetaItemBehaviorHints, PosterShape};
use chrono::prelude::TimeZone;
use chrono::Utc;
+use std::fmt::Write;
#[test]
fn deserialize_meta_item() {
@@ -64,9 +65,12 @@ fn deserialize_meta_item() {
behavior_hints: MetaItemBehaviorHints::default(),
},
];
- let meta_items_json = r#"
+ let mut meta_items_json = "".to_string();
+ write!(
+ meta_items_json,
+ r#"
[
- {
+ {{
"id": "id1",
"type": "type_name",
"name": "name",
@@ -82,13 +86,9 @@ fn deserialize_meta_item() {
"videos": [],
"links": [],
"trailerStreams": [],
- "behaviorHints": {
- "defaultVideoId": null,
- "featuredVideoId": null,
- "has_scheduled_videos": false
- }
- },
- {
+ "behaviorHints": {}
+ }},
+ {{
"id": "id2",
"type": "type_name",
"poster": null,
@@ -99,8 +99,8 @@ fn deserialize_meta_item() {
"releaseInfo": null,
"runtime": null,
"released": null
- },
- {
+ }},
+ {{
"id": "id3",
"type": "type_name",
"name": "name",
@@ -116,14 +116,14 @@ fn deserialize_meta_item() {
"videos": [],
"links": [],
"trailerStreams": [],
- "behaviorHints": {
- "defaultVideoId": null,
- "featuredVideoId": null,
- "has_scheduled_videos": false
- }
- }
+ "behaviorHints": {}
+ }}
]
- "#;
+ "#,
+ serde_json::to_string(&MetaItemBehaviorHints::default()).unwrap(),
+ serde_json::to_string(&MetaItemBehaviorHints::default()).unwrap()
+ )
+ .unwrap();
let meta_items_deserialize: Vec<MetaItem> = serde_json::from_str(&meta_items_json).unwrap();
assert_eq!(
meta_items, meta_items_deserialize,
