fix(readarr): tolerate book payloads that omit the grabbed flag
This commit is contained in:
2 files changed
+17
No files matched your search
@@ -280,6 +280,7 @@ pub struct Book {
|
|||||||
pub ratings: Option<Ratings>,
|
pub ratings: Option<Ratings>,
|
||||||
pub release_date: Option<DateTime<Utc>>,
|
pub release_date: Option<DateTime<Utc>>,
|
||||||
pub statistics: Option<BookStatistics>,
|
pub statistics: Option<BookStatistics>,
|
||||||
|
#[serde(default)]
|
||||||
pub grabbed: bool,
|
pub grabbed: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -939,6 +939,22 @@ mod tests {
|
|||||||
assert_none!(&book.statistics);
|
assert_none!(&book.statistics);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_book_deserialization_defaults_grabbed_when_absent() {
|
||||||
|
let book_json = json!({
|
||||||
|
"id": 1,
|
||||||
|
"title": "The Name of the Wind",
|
||||||
|
"authorId": 3,
|
||||||
|
"foreignBookId": "test-foreign-book-id",
|
||||||
|
"monitored": true
|
||||||
|
});
|
||||||
|
|
||||||
|
let book: Book = serde_json::from_value(book_json).unwrap();
|
||||||
|
|
||||||
|
assert!(!book.grabbed);
|
||||||
|
assert!(book.monitored);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_edition_deserialization() {
|
fn test_edition_deserialization() {
|
||||||
let edition_json = json!({
|
let edition_json = json!({
|
||||||
|
|||||||
Reference in new issue
Block a user