From 1336c211f9c67fb77ebab5873166c9c4839dfa25 Mon Sep 17 00:00:00 2001 From: Wojciech Kozlowski Date: Fri, 19 May 2023 22:22:42 +0200 Subject: [PATCH] Test new database error --- src/database/json/mod.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/database/json/mod.rs b/src/database/json/mod.rs index a1fd666..dbed862 100644 --- a/src/database/json/mod.rs +++ b/src/database/json/mod.rs @@ -67,7 +67,7 @@ mod tests { use super::*; - use crate::{tests::COLLECTION, Artist, ArtistId, Format}; + use crate::{tests::COLLECTION, Artist, ArtistId, Format, Collection}; fn artist_to_json(artist: &Artist) -> String { let album_artist = &artist.id.name; @@ -186,7 +186,18 @@ mod tests { } #[test] - fn errors() { + fn load_errors() { + let json = String::from(""); + let serde_err = serde_json::from_str::(&json); + assert!(serde_err.is_err()); + + let serde_err: LoadError = serde_err.unwrap_err().into(); + assert!(!serde_err.to_string().is_empty()); + assert!(!format!("{:?}", serde_err).is_empty()); + } + + #[test] + fn save_errors() { let mut object = HashMap::::new(); object.insert( ArtistId {