Limit the information stored in the database #126

Merged
wojtek merged 8 commits from 118---limit-the-information-stored-in-the-database into main 2024-02-10 20:23:10 +01:00
2 changed files with 14 additions and 27 deletions
Showing only changes of commit 6b8c7c40fa - Show all commits

View File

@ -10,7 +10,7 @@ use std::fmt;
#[cfg(test)]
use mockall::automock;
use crate::core::collection::Collection;
use crate::core::collection::{self, Collection};
/// Trait for interacting with the database.
#[cfg_attr(test, automock)]
@ -61,6 +61,14 @@ impl From<std::io::Error> for LoadError {
}
}
impl From<collection::Error> for LoadError {
fn from(err: collection::Error) -> Self {
match err {
collection::Error::UrlError(e) => LoadError::SerDeError(e),
}
}
}
/// Error type for database calls.
#[derive(Debug)]
pub enum SaveError {
@ -111,6 +119,10 @@ mod tests {
assert!(!io_err.to_string().is_empty());
assert!(!format!("{:?}", io_err).is_empty());
let col_err: LoadError = collection::Error::UrlError(String::from("get rekt")).into();
assert!(!col_err.to_string().is_empty());
assert!(!format!("{:?}", col_err).is_empty());
let io_err: SaveError = io::Error::new(io::ErrorKind::Interrupted, "error").into();
assert!(!io_err.to_string().is_empty());
assert!(!format!("{:?}", io_err).is_empty());

View File

@ -3,10 +3,7 @@ use std::collections::HashMap;
use serde::Deserialize;
use crate::{
collection::{
self,
artist::{ArtistId, MusicBrainz},
},
collection::artist::{ArtistId, MusicBrainz},
core::{
collection::{artist::Artist, Collection},
database::{serde::Database, LoadError},
@ -49,25 +46,3 @@ impl TryFrom<DeserializeArtist> for Artist {
})
}
}
impl From<collection::Error> for LoadError {
fn from(err: collection::Error) -> Self {
match err {
collection::Error::UrlError(e) => LoadError::SerDeError(e),
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn errors() {
let col_err: LoadError = collection::Error::UrlError(String::from("get rekt")).into();
assert!(!col_err.to_string().is_empty());
assert!(!format!("{:?}", col_err).is_empty());
}
}