fix(radarr): serialize the credit type under the same key it is read from
Radarr sends and accepts the credit type as "type" in both directions, but the field was only renamed for deserialization, so serializing a Credit emitted "creditType" and a to_value round trip could not be read back. Credit is only deserialized in production, so this affects tests and any future serialization of the record, not the live API traffic.
This commit is contained in:
2 files changed
+13
-4
No files matched your search
@@ -127,10 +127,7 @@ pub struct Credit {
|
|||||||
pub character: Option<String>,
|
pub character: Option<String>,
|
||||||
pub department: Option<String>,
|
pub department: Option<String>,
|
||||||
pub job: Option<String>,
|
pub job: Option<String>,
|
||||||
#[serde(
|
#[serde(rename = "type", deserialize_with = "super::from_json_or_default")]
|
||||||
rename(deserialize = "type"),
|
|
||||||
deserialize_with = "super::from_json_or_default"
|
|
||||||
)]
|
|
||||||
pub credit_type: CreditType,
|
pub credit_type: CreditType,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -260,6 +260,18 @@ mod tests {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_credit_serializes_credit_type_under_the_type_key() {
|
||||||
|
let credit_json = serde_json::to_value(crew_credit()).unwrap();
|
||||||
|
|
||||||
|
assert_eq!(credit_json["type"], json!("crew"));
|
||||||
|
assert_none!(credit_json.get("creditType"));
|
||||||
|
assert_eq!(
|
||||||
|
serde_json::from_value::<Credit>(credit_json).unwrap(),
|
||||||
|
crew_credit()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_download_record_default_indexer_value() {
|
fn test_download_record_default_indexer_value() {
|
||||||
let json = r#"{
|
let json = r#"{
|
||||||
|
|||||||
Reference in new issue
Block a user