From 8667f6a473a1d4e09afa9bee9247d63ce6db2f92 Mon Sep 17 00:00:00 2001 From: Wojciech Kozlowski Date: Thu, 2 Jan 2025 12:49:28 +0100 Subject: [PATCH] Add an alike method --- src/core/collection/album.rs | 17 ++- src/core/collection/artist.rs | 2 +- src/core/collection/merge.rs | 8 -- src/core/interface/library/mod.rs | 3 + src/core/interface/library/testmod.rs | 44 +++---- src/external/database/json/testmod.rs | 20 ++-- src/external/database/serde/common.rs | 2 +- src/external/library/beets/mod.rs | 2 +- src/testmod/full.rs | 20 ++-- src/testmod/library.rs | 20 ++-- src/tui/ui/display.rs | 9 +- tests/files/database/database.json | 2 +- tests/library/testmod.rs | 158 +++++++++++++------------- tests/testlib.rs | 14 +-- 14 files changed, 164 insertions(+), 157 deletions(-) diff --git a/src/core/collection/album.rs b/src/core/collection/album.rs index 26a02fe..c10f9d5 100644 --- a/src/core/collection/album.rs +++ b/src/core/collection/album.rs @@ -40,10 +40,19 @@ pub struct AlbumId { pub lib_id: AlbumLibId, } +impl AlbumId { + pub fn alike(&self, other: &AlbumId) -> bool { + let titles_alike = self.title == other.title; + let lib_id_alike = + self.lib_id.is_none() || other.lib_id.is_none() || (self.lib_id == other.lib_id); + titles_alike && lib_id_alike + } +} + /// Unique library identifier. #[derive(Clone, Copy, Debug, PartialEq, PartialOrd, Ord, Eq, Hash)] pub enum AlbumLibId { - Some(u32), + Value(u32), Singleton, None, } @@ -259,11 +268,7 @@ impl Ord for AlbumMeta { impl Merge for AlbumMeta { fn merge_in_place(&mut self, other: Self) { - if !self.id.lib_id.is_none() && !other.id.lib_id.is_none() { - assert_eq!(self.id, other.id); - } else { - assert_eq!(self.id.title, other.id.title); - } + assert!(self.id.alike(&other.id)); self.seq = std::cmp::max(self.seq, other.seq); diff --git a/src/core/collection/artist.rs b/src/core/collection/artist.rs index a627e5b..3375ade 100644 --- a/src/core/collection/artist.rs +++ b/src/core/collection/artist.rs @@ -61,7 +61,7 @@ impl Artist { primary_albums: &mut [Album], mut secondary_album: Album, ) -> Option { - if let lib_id @ AlbumLibId::Some(_) | lib_id @ AlbumLibId::Singleton = + if let lib_id @ AlbumLibId::Value(_) | lib_id @ AlbumLibId::Singleton = secondary_album.meta.id.lib_id { if let Some(ref mut primary_album) = primary_albums diff --git a/src/core/collection/merge.rs b/src/core/collection/merge.rs index 704e8e6..ebfed09 100644 --- a/src/core/collection/merge.rs +++ b/src/core/collection/merge.rs @@ -98,14 +98,6 @@ where T: MergeId + Merge + Ord, IT: IntoIterator, { - pub fn merge_iter(primary: IT, secondary: IT) -> Vec { - let primary = primary - .into_iter() - .map(|item| (item.id().clone(), item)) - .collect(); - Self::merge(primary, secondary) - } - pub fn merge(mut primary: HashMap, secondary: IT) -> Vec { for secondary_item in secondary { if let Some(ref mut primary_item) = primary.get_mut(secondary_item.id()) { diff --git a/src/core/interface/library/mod.rs b/src/core/interface/library/mod.rs index 190f728..0cdce85 100644 --- a/src/core/interface/library/mod.rs +++ b/src/core/interface/library/mod.rs @@ -177,6 +177,7 @@ mod tests { let exe_err = Error::Executor(String::from("Executor")); let io_err: Error = io::Error::new(io::ErrorKind::Interrupted, "Interrupted").into(); let inv_err = Error::Invalid(String::from("Invalid")); + let bool_err: Error = "f".parse::().unwrap_err().into(); let int_err: Error = "five".parse::().unwrap_err().into(); #[allow(invalid_from_utf8)] let utf_err: Error = std::str::from_utf8(b"\xe2\x28\xa1").unwrap_err().into(); @@ -184,12 +185,14 @@ mod tests { assert!(!exe_err.to_string().is_empty()); assert!(!io_err.to_string().is_empty()); assert!(!inv_err.to_string().is_empty()); + assert!(!bool_err.to_string().is_empty()); assert!(!int_err.to_string().is_empty()); assert!(!utf_err.to_string().is_empty()); assert!(!format!("{:?}", exe_err).is_empty()); assert!(!format!("{:?}", io_err).is_empty()); assert!(!format!("{:?}", inv_err).is_empty()); + assert!(!format!("{:?}", bool_err).is_empty()); assert!(!format!("{:?}", int_err).is_empty()); assert!(!format!("{:?}", utf_err).is_empty()); } diff --git a/src/core/interface/library/testmod.rs b/src/core/interface/library/testmod.rs index 4e447c0..43408b6 100644 --- a/src/core/interface/library/testmod.rs +++ b/src/core/interface/library/testmod.rs @@ -14,7 +14,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("album_title a.a"), - album_lib_id: AlbumLibId::Some(1), + album_lib_id: AlbumLibId::Value(1), track_number: 1, track_title: String::from("track a.a.1"), track_artist: vec![String::from("artist a.a.1")], @@ -28,7 +28,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("album_title a.a"), - album_lib_id: AlbumLibId::Some(1), + album_lib_id: AlbumLibId::Value(1), track_number: 2, track_title: String::from("track a.a.2"), track_artist: vec![ @@ -45,7 +45,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("album_title a.a"), - album_lib_id: AlbumLibId::Some(1), + album_lib_id: AlbumLibId::Value(1), track_number: 3, track_title: String::from("track a.a.3"), track_artist: vec![String::from("artist a.a.3")], @@ -59,7 +59,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("album_title a.a"), - album_lib_id: AlbumLibId::Some(1), + album_lib_id: AlbumLibId::Value(1), track_number: 4, track_title: String::from("track a.a.4"), track_artist: vec![String::from("artist a.a.4")], @@ -73,7 +73,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 4, album_day: 0, album_title: String::from("album_title a.b"), - album_lib_id: AlbumLibId::Some(2), + album_lib_id: AlbumLibId::Value(2), track_number: 1, track_title: String::from("track a.b.1"), track_artist: vec![String::from("artist a.b.1")], @@ -87,7 +87,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 4, album_day: 0, album_title: String::from("album_title a.b"), - album_lib_id: AlbumLibId::Some(2), + album_lib_id: AlbumLibId::Value(2), track_number: 2, track_title: String::from("track a.b.2"), track_artist: vec![String::from("artist a.b.2")], @@ -101,7 +101,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 6, album_day: 6, album_title: String::from("album_title b.a"), - album_lib_id: AlbumLibId::Some(3), + album_lib_id: AlbumLibId::Value(3), track_number: 1, track_title: String::from("track b.a.1"), track_artist: vec![String::from("artist b.a.1")], @@ -115,7 +115,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 6, album_day: 6, album_title: String::from("album_title b.a"), - album_lib_id: AlbumLibId::Some(3), + album_lib_id: AlbumLibId::Value(3), track_number: 2, track_title: String::from("track b.a.2"), track_artist: vec![ @@ -132,7 +132,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("album_title b.b"), - album_lib_id: AlbumLibId::Some(4), + album_lib_id: AlbumLibId::Value(4), track_number: 1, track_title: String::from("track b.b.1"), track_artist: vec![String::from("artist b.b.1")], @@ -146,7 +146,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("album_title b.b"), - album_lib_id: AlbumLibId::Some(4), + album_lib_id: AlbumLibId::Value(4), track_number: 2, track_title: String::from("track b.b.2"), track_artist: vec![ @@ -163,7 +163,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("album_title b.c"), - album_lib_id: AlbumLibId::Some(5), + album_lib_id: AlbumLibId::Value(5), track_number: 1, track_title: String::from("track b.c.1"), track_artist: vec![String::from("artist b.c.1")], @@ -177,7 +177,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("album_title b.c"), - album_lib_id: AlbumLibId::Some(5), + album_lib_id: AlbumLibId::Value(5), track_number: 2, track_title: String::from("track b.c.2"), track_artist: vec![ @@ -194,7 +194,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("album_title b.d"), - album_lib_id: AlbumLibId::Some(6), + album_lib_id: AlbumLibId::Value(6), track_number: 1, track_title: String::from("track b.d.1"), track_artist: vec![String::from("artist b.d.1")], @@ -208,7 +208,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("album_title b.d"), - album_lib_id: AlbumLibId::Some(6), + album_lib_id: AlbumLibId::Value(6), track_number: 2, track_title: String::from("track b.d.2"), track_artist: vec![ @@ -225,7 +225,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("album_title c.a"), - album_lib_id: AlbumLibId::Some(7), + album_lib_id: AlbumLibId::Value(7), track_number: 1, track_title: String::from("track c.a.1"), track_artist: vec![String::from("artist c.a.1")], @@ -239,7 +239,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("album_title c.a"), - album_lib_id: AlbumLibId::Some(7), + album_lib_id: AlbumLibId::Value(7), track_number: 2, track_title: String::from("track c.a.2"), track_artist: vec![ @@ -256,7 +256,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("album_title c.b"), - album_lib_id: AlbumLibId::Some(8), + album_lib_id: AlbumLibId::Value(8), track_number: 1, track_title: String::from("track c.b.1"), track_artist: vec![String::from("artist c.b.1")], @@ -270,7 +270,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("album_title c.b"), - album_lib_id: AlbumLibId::Some(8), + album_lib_id: AlbumLibId::Value(8), track_number: 2, track_title: String::from("track c.b.2"), track_artist: vec![ @@ -287,7 +287,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("album_title d.a"), - album_lib_id: AlbumLibId::Some(9), + album_lib_id: AlbumLibId::Value(9), track_number: 1, track_title: String::from("track d.a.1"), track_artist: vec![String::from("artist d.a.1")], @@ -301,7 +301,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("album_title d.a"), - album_lib_id: AlbumLibId::Some(9), + album_lib_id: AlbumLibId::Value(9), track_number: 2, track_title: String::from("track d.a.2"), track_artist: vec![ @@ -318,7 +318,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("album_title d.b"), - album_lib_id: AlbumLibId::Some(10), + album_lib_id: AlbumLibId::Value(10), track_number: 1, track_title: String::from("track d.b.1"), track_artist: vec![String::from("artist d.b.1")], @@ -332,7 +332,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("album_title d.b"), - album_lib_id: AlbumLibId::Some(10), + album_lib_id: AlbumLibId::Value(10), track_number: 2, track_title: String::from("track d.b.2"), track_artist: vec![ diff --git a/src/external/database/json/testmod.rs b/src/external/database/json/testmod.rs index 31dae78..0f2f602 100644 --- a/src/external/database/json/testmod.rs +++ b/src/external/database/json/testmod.rs @@ -11,12 +11,12 @@ pub static DATABASE_JSON: &str = "{\ },\ \"albums\":[\ {\ - \"title\":\"album_title a.a\",\"lib_id\":{\"Some\":1},\"seq\":1,\ + \"title\":\"album_title a.a\",\"lib_id\":{\"Value\":1},\"seq\":1,\ \"musicbrainz\":{\"Some\":\"00000000-0000-0000-0000-000000000000\"},\ \"primary_type\":\"Album\",\"secondary_types\":[]\ },\ {\ - \"title\":\"album_title a.b\",\"lib_id\":{\"Some\":2},\"seq\":1,\"musicbrainz\":\"None\",\ + \"title\":\"album_title a.b\",\"lib_id\":{\"Value\":2},\"seq\":1,\"musicbrainz\":\"None\",\ \"primary_type\":\"Album\",\"secondary_types\":[]\ }\ ]\ @@ -35,21 +35,21 @@ pub static DATABASE_JSON: &str = "{\ },\ \"albums\":[\ {\ - \"title\":\"album_title b.a\",\"lib_id\":{\"Some\":3},\"seq\":1,\"musicbrainz\":\"None\",\ + \"title\":\"album_title b.a\",\"lib_id\":{\"Value\":3},\"seq\":1,\"musicbrainz\":\"None\",\ \"primary_type\":\"Album\",\"secondary_types\":[]\ },\ {\ - \"title\":\"album_title b.b\",\"lib_id\":{\"Some\":4},\"seq\":3,\ + \"title\":\"album_title b.b\",\"lib_id\":{\"Value\":4},\"seq\":3,\ \"musicbrainz\":{\"Some\":\"11111111-1111-1111-1111-111111111111\"},\ \"primary_type\":\"Album\",\"secondary_types\":[]\ },\ {\ - \"title\":\"album_title b.c\",\"lib_id\":{\"Some\":5},\"seq\":2,\ + \"title\":\"album_title b.c\",\"lib_id\":{\"Value\":5},\"seq\":2,\ \"musicbrainz\":{\"Some\":\"11111111-1111-1111-1111-111111111112\"},\ \"primary_type\":\"Album\",\"secondary_types\":[]\ },\ {\ - \"title\":\"album_title b.d\",\"lib_id\":{\"Some\":6},\"seq\":4,\"musicbrainz\":\"None\",\ + \"title\":\"album_title b.d\",\"lib_id\":{\"Value\":6},\"seq\":4,\"musicbrainz\":\"None\",\ \"primary_type\":\"Album\",\"secondary_types\":[]\ }\ ]\ @@ -61,11 +61,11 @@ pub static DATABASE_JSON: &str = "{\ \"properties\":{},\ \"albums\":[\ {\ - \"title\":\"album_title c.a\",\"lib_id\":{\"Some\":7},\"seq\":0,\"musicbrainz\":\"None\",\ + \"title\":\"album_title c.a\",\"lib_id\":{\"Value\":7},\"seq\":0,\"musicbrainz\":\"None\",\ \"primary_type\":\"Album\",\"secondary_types\":[]\ },\ {\ - \"title\":\"album_title c.b\",\"lib_id\":{\"Some\":8},\"seq\":0,\"musicbrainz\":\"None\",\ + \"title\":\"album_title c.b\",\"lib_id\":{\"Value\":8},\"seq\":0,\"musicbrainz\":\"None\",\ \"primary_type\":\"Album\",\"secondary_types\":[]\ }\ ]\ @@ -77,11 +77,11 @@ pub static DATABASE_JSON: &str = "{\ \"properties\":{},\ \"albums\":[\ {\ - \"title\":\"album_title d.a\",\"lib_id\":{\"Some\":9},\"seq\":0,\"musicbrainz\":\"None\",\ + \"title\":\"album_title d.a\",\"lib_id\":{\"Value\":9},\"seq\":0,\"musicbrainz\":\"None\",\ \"primary_type\":\"Album\",\"secondary_types\":[]\ },\ {\ - \"title\":\"album_title d.b\",\"lib_id\":{\"Some\":10},\"seq\":0,\"musicbrainz\":\"None\",\ + \"title\":\"album_title d.b\",\"lib_id\":{\"Value\":10},\"seq\":0,\"musicbrainz\":\"None\",\ \"primary_type\":\"Album\",\"secondary_types\":[]\ }\ ]\ diff --git a/src/external/database/serde/common.rs b/src/external/database/serde/common.rs index fdf9827..ff75896 100644 --- a/src/external/database/serde/common.rs +++ b/src/external/database/serde/common.rs @@ -8,7 +8,7 @@ use crate::{ #[derive(Debug, Deserialize, Serialize)] #[serde(remote = "AlbumLibId")] pub enum AlbumLibIdDef { - Some(u32), + Value(u32), Singleton, None, } diff --git a/src/external/library/beets/mod.rs b/src/external/library/beets/mod.rs index 2cbfd9d..e72bf56 100644 --- a/src/external/library/beets/mod.rs +++ b/src/external/library/beets/mod.rs @@ -167,7 +167,7 @@ impl BeetsLibrary { let album_title = split[6].to_string(); let album_lib_id = match singleton { true => AlbumLibId::Singleton, - false => AlbumLibId::Some(split[7].parse::()?), + false => AlbumLibId::Value(split[7].parse::()?), }; let track_number = split[8].parse::()?; let track_title = split[9].to_string(); diff --git a/src/testmod/full.rs b/src/testmod/full.rs index 96805ad..87e1cbc 100644 --- a/src/testmod/full.rs +++ b/src/testmod/full.rs @@ -28,7 +28,7 @@ macro_rules! full_collection { meta: AlbumMeta { id: AlbumId { title: "album_title a.a".to_string(), - lib_id: AlbumLibId::Some(1), + lib_id: AlbumLibId::Value(1), }, date: 1998.into(), seq: AlbumSeq(1), @@ -94,7 +94,7 @@ macro_rules! full_collection { meta: AlbumMeta { id: AlbumId { title: "album_title a.b".to_string(), - lib_id: AlbumLibId::Some(2), + lib_id: AlbumLibId::Value(2), }, date: (2015, 4).into(), seq: AlbumSeq(1), @@ -162,7 +162,7 @@ macro_rules! full_collection { meta: AlbumMeta { id: AlbumId { title: "album_title b.a".to_string(), - lib_id: AlbumLibId::Some(3), + lib_id: AlbumLibId::Value(3), }, date: (2003, 6, 6).into(), seq: AlbumSeq(1), @@ -204,7 +204,7 @@ macro_rules! full_collection { meta: AlbumMeta { id: AlbumId { title: "album_title b.b".to_string(), - lib_id: AlbumLibId::Some(4), + lib_id: AlbumLibId::Value(4), }, date: 2008.into(), seq: AlbumSeq(3), @@ -248,7 +248,7 @@ macro_rules! full_collection { meta: AlbumMeta { id: AlbumId { title: "album_title b.c".to_string(), - lib_id: AlbumLibId::Some(5), + lib_id: AlbumLibId::Value(5), }, date: 2009.into(), seq: AlbumSeq(2), @@ -292,7 +292,7 @@ macro_rules! full_collection { meta: AlbumMeta { id: AlbumId { title: "album_title b.d".to_string(), - lib_id: AlbumLibId::Some(6), + lib_id: AlbumLibId::Value(6), }, date: 2015.into(), seq: AlbumSeq(4), @@ -348,7 +348,7 @@ macro_rules! full_collection { meta: AlbumMeta { id: AlbumId { title: "album_title c.a".to_string(), - lib_id: AlbumLibId::Some(7), + lib_id: AlbumLibId::Value(7), }, date: 1985.into(), seq: AlbumSeq(0), @@ -390,7 +390,7 @@ macro_rules! full_collection { meta: AlbumMeta { id: AlbumId { title: "album_title c.b".to_string(), - lib_id: AlbumLibId::Some(8), + lib_id: AlbumLibId::Value(8), }, date: 2018.into(), seq: AlbumSeq(0), @@ -446,7 +446,7 @@ macro_rules! full_collection { meta: AlbumMeta { id: AlbumId { title: "album_title d.a".to_string(), - lib_id: AlbumLibId::Some(9), + lib_id: AlbumLibId::Value(9), }, date: 1995.into(), seq: AlbumSeq(0), @@ -488,7 +488,7 @@ macro_rules! full_collection { meta: AlbumMeta { id: AlbumId { title: "album_title d.b".to_string(), - lib_id: AlbumLibId::Some(10), + lib_id: AlbumLibId::Value(10), }, date: 2028.into(), seq: AlbumSeq(0), diff --git a/src/testmod/library.rs b/src/testmod/library.rs index 5e7a354..a50b16c 100644 --- a/src/testmod/library.rs +++ b/src/testmod/library.rs @@ -18,7 +18,7 @@ macro_rules! library_collection { meta: AlbumMeta { id: AlbumId { title: "album_title a.a".to_string(), - lib_id: AlbumLibId::Some(1), + lib_id: AlbumLibId::Value(1), }, date: 1998.into(), seq: AlbumSeq(0), @@ -78,7 +78,7 @@ macro_rules! library_collection { meta: AlbumMeta { id: AlbumId { title: "album_title a.b".to_string(), - lib_id: AlbumLibId::Some(2), + lib_id: AlbumLibId::Value(2), }, date: (2015, 4).into(), seq: AlbumSeq(0), @@ -127,7 +127,7 @@ macro_rules! library_collection { meta: AlbumMeta { id: AlbumId { title: "album_title b.a".to_string(), - lib_id: AlbumLibId::Some(3), + lib_id: AlbumLibId::Value(3), }, date: (2003, 6, 6).into(), seq: AlbumSeq(0), @@ -165,7 +165,7 @@ macro_rules! library_collection { meta: AlbumMeta { id: AlbumId { title: "album_title b.b".to_string(), - lib_id: AlbumLibId::Some(4), + lib_id: AlbumLibId::Value(4), }, date: 2008.into(), seq: AlbumSeq(0), @@ -203,7 +203,7 @@ macro_rules! library_collection { meta: AlbumMeta { id: AlbumId { title: "album_title b.c".to_string(), - lib_id: AlbumLibId::Some(5), + lib_id: AlbumLibId::Value(5), }, date: 2009.into(), seq: AlbumSeq(0), @@ -241,7 +241,7 @@ macro_rules! library_collection { meta: AlbumMeta { id: AlbumId { title: "album_title b.d".to_string(), - lib_id: AlbumLibId::Some(6), + lib_id: AlbumLibId::Value(6), }, date: 2015.into(), seq: AlbumSeq(0), @@ -293,7 +293,7 @@ macro_rules! library_collection { meta: AlbumMeta { id: AlbumId { title: "album_title c.a".to_string(), - lib_id: AlbumLibId::Some(7), + lib_id: AlbumLibId::Value(7), }, date: 1985.into(), seq: AlbumSeq(0), @@ -331,7 +331,7 @@ macro_rules! library_collection { meta: AlbumMeta { id: AlbumId { title: "album_title c.b".to_string(), - lib_id: AlbumLibId::Some(8), + lib_id: AlbumLibId::Value(8), }, date: 2018.into(), seq: AlbumSeq(0), @@ -383,7 +383,7 @@ macro_rules! library_collection { meta: AlbumMeta { id: AlbumId { title: "album_title d.a".to_string(), - lib_id: AlbumLibId::Some(9), + lib_id: AlbumLibId::Value(9), }, date: 1995.into(), seq: AlbumSeq(0), @@ -421,7 +421,7 @@ macro_rules! library_collection { meta: AlbumMeta { id: AlbumId { title: "album_title d.b".to_string(), - lib_id: AlbumLibId::Some(10), + lib_id: AlbumLibId::Value(10), }, date: 2028.into(), seq: AlbumSeq(0), diff --git a/src/tui/ui/display.rs b/src/tui/ui/display.rs index b31da07..07efca1 100644 --- a/src/tui/ui/display.rs +++ b/src/tui/ui/display.rs @@ -23,7 +23,7 @@ impl UiDisplay { pub fn display_album_lib_id(lib_id: &AlbumLibId) -> String { match lib_id { - AlbumLibId::Some(val) => val.to_string(), + AlbumLibId::Value(val) => val.to_string(), AlbumLibId::Singleton => "Singleton".to_string(), AlbumLibId::None => "None".to_string(), } @@ -205,6 +205,13 @@ mod tests { ); } + #[test] + fn display_album_lib_id() { + assert_eq!(UiDisplay::display_album_lib_id(&AlbumLibId::Value(5)), "5"); + assert_eq!(UiDisplay::display_album_lib_id(&AlbumLibId::Singleton), "Singleton"); + assert_eq!(UiDisplay::display_album_lib_id(&AlbumLibId::None), "None"); + } + #[test] fn display_date() { let date: AlbumDate = 1990.into(); diff --git a/tests/files/database/database.json b/tests/files/database/database.json index e0420a3..93fb18a 100644 --- a/tests/files/database/database.json +++ b/tests/files/database/database.json @@ -1 +1 @@ -{"V20250101":[{"name":"Аркона","sort":"Arkona","musicbrainz":{"Some":"baad262d-55ef-427a-83c7-f7530964f212"},"properties":{"Bandcamp":["https://arkonamoscow.bandcamp.com/"],"MusicButler":["https://www.musicbutler.io/artist-page/283448581"],"Qobuz":["https://www.qobuz.com/nl-nl/interpreter/arkona/download-streaming-albums"]},"albums":[{"title":"Slovo","lib_id":{"Some":7},"seq":0,"musicbrainz":"None","primary_type":"Album","secondary_types":[]}]},{"name":"Eluveitie","sort":null,"musicbrainz":{"Some":"8000598a-5edb-401c-8e6d-36b167feaf38"},"properties":{"MusicButler":["https://www.musicbutler.io/artist-page/269358403"],"Qobuz":["https://www.qobuz.com/nl-nl/interpreter/eluveitie/download-streaming-albums"]},"albums":[{"title":"Vên [re‐recorded]","lib_id":{"Some":1},"seq":0,"musicbrainz":"None","primary_type":"Ep","secondary_types":[]},{"title":"Slania","lib_id":{"Some":2},"seq":0,"musicbrainz":"None","primary_type":"Album","secondary_types":[]}]},{"name":"Frontside","sort":null,"musicbrainz":{"Some":"3a901353-fccd-4afd-ad01-9c03f451b490"},"properties":{"MusicButler":["https://www.musicbutler.io/artist-page/826588800"],"Qobuz":["https://www.qobuz.com/nl-nl/interpreter/frontside/download-streaming-albums"]},"albums":[{"title":"…nasze jest królestwo, potęga i chwała na wieki…","lib_id":{"Some":3},"seq":0,"musicbrainz":"None","primary_type":"Album","secondary_types":[]}]},{"name":"Heaven’s Basement","sort":"Heaven’s Basement","musicbrainz":{"Some":"c2c4d56a-d599-4a18-bd2f-ae644e2198cc"},"properties":{"MusicButler":["https://www.musicbutler.io/artist-page/291158685"],"Qobuz":["https://www.qobuz.com/nl-nl/interpreter/heaven-s-basement/download-streaming-albums"]},"albums":[{"title":"Paper Plague","lib_id":"Singleton","seq":0,"musicbrainz":"None","primary_type":null,"secondary_types":[]},{"title":"Unbreakable","lib_id":{"Some":4},"seq":0,"musicbrainz":"None","primary_type":"Album","secondary_types":[]}]},{"name":"Metallica","sort":null,"musicbrainz":{"Some":"65f4f0c5-ef9e-490c-aee3-909e7ae6b2ab"},"properties":{"MusicButler":["https://www.musicbutler.io/artist-page/3996865"],"Qobuz":["https://www.qobuz.com/nl-nl/interpreter/metallica/download-streaming-albums"]},"albums":[{"title":"Ride the Lightning","lib_id":{"Some":5},"seq":0,"musicbrainz":"None","primary_type":"Album","secondary_types":[]},{"title":"S&M","lib_id":{"Some":6},"seq":0,"musicbrainz":"None","primary_type":"Album","secondary_types":["Live"]}]}]} \ No newline at end of file +{"V20250101":[{"name":"Аркона","sort":"Arkona","musicbrainz":{"Some":"baad262d-55ef-427a-83c7-f7530964f212"},"properties":{"Bandcamp":["https://arkonamoscow.bandcamp.com/"],"MusicButler":["https://www.musicbutler.io/artist-page/283448581"],"Qobuz":["https://www.qobuz.com/nl-nl/interpreter/arkona/download-streaming-albums"]},"albums":[{"title":"Slovo","lib_id":{"Value":7},"seq":0,"musicbrainz":"None","primary_type":"Album","secondary_types":[]}]},{"name":"Eluveitie","sort":null,"musicbrainz":{"Some":"8000598a-5edb-401c-8e6d-36b167feaf38"},"properties":{"MusicButler":["https://www.musicbutler.io/artist-page/269358403"],"Qobuz":["https://www.qobuz.com/nl-nl/interpreter/eluveitie/download-streaming-albums"]},"albums":[{"title":"Vên [re‐recorded]","lib_id":{"Value":1},"seq":0,"musicbrainz":"None","primary_type":"Ep","secondary_types":[]},{"title":"Slania","lib_id":{"Value":2},"seq":0,"musicbrainz":"None","primary_type":"Album","secondary_types":[]}]},{"name":"Frontside","sort":null,"musicbrainz":{"Some":"3a901353-fccd-4afd-ad01-9c03f451b490"},"properties":{"MusicButler":["https://www.musicbutler.io/artist-page/826588800"],"Qobuz":["https://www.qobuz.com/nl-nl/interpreter/frontside/download-streaming-albums"]},"albums":[{"title":"…nasze jest królestwo, potęga i chwała na wieki…","lib_id":{"Value":3},"seq":0,"musicbrainz":"None","primary_type":"Album","secondary_types":[]}]},{"name":"Heaven’s Basement","sort":"Heaven’s Basement","musicbrainz":{"Some":"c2c4d56a-d599-4a18-bd2f-ae644e2198cc"},"properties":{"MusicButler":["https://www.musicbutler.io/artist-page/291158685"],"Qobuz":["https://www.qobuz.com/nl-nl/interpreter/heaven-s-basement/download-streaming-albums"]},"albums":[{"title":"Paper Plague","lib_id":"Singleton","seq":0,"musicbrainz":"None","primary_type":null,"secondary_types":[]},{"title":"Unbreakable","lib_id":{"Value":4},"seq":0,"musicbrainz":"None","primary_type":"Album","secondary_types":[]}]},{"name":"Metallica","sort":null,"musicbrainz":{"Some":"65f4f0c5-ef9e-490c-aee3-909e7ae6b2ab"},"properties":{"MusicButler":["https://www.musicbutler.io/artist-page/3996865"],"Qobuz":["https://www.qobuz.com/nl-nl/interpreter/metallica/download-streaming-albums"]},"albums":[{"title":"Ride the Lightning","lib_id":{"Value":5},"seq":0,"musicbrainz":"None","primary_type":"Album","secondary_types":[]},{"title":"S&M","lib_id":{"Value":6},"seq":0,"musicbrainz":"None","primary_type":"Album","secondary_types":["Live"]}]}]} \ No newline at end of file diff --git a/tests/library/testmod.rs b/tests/library/testmod.rs index 36cd26d..9889663 100644 --- a/tests/library/testmod.rs +++ b/tests/library/testmod.rs @@ -14,7 +14,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("Slovo"), - album_lib_id: AlbumLibId::Some(7), + album_lib_id: AlbumLibId::Value(7), track_number: 1, track_title: String::from("Az’"), track_artist: vec![String::from("Аркона")], @@ -28,7 +28,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("Slovo"), - album_lib_id: AlbumLibId::Some(7), + album_lib_id: AlbumLibId::Value(7), track_number: 2, track_title: String::from("Arkaim"), track_artist: vec![String::from("Аркона")], @@ -42,7 +42,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("Slovo"), - album_lib_id: AlbumLibId::Some(7), + album_lib_id: AlbumLibId::Value(7), track_number: 3, track_title: String::from("Bol’no mne"), track_artist: vec![String::from("Аркона")], @@ -56,7 +56,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("Slovo"), - album_lib_id: AlbumLibId::Some(7), + album_lib_id: AlbumLibId::Value(7), track_number: 4, track_title: String::from("Leshiy"), track_artist: vec![String::from("Аркона")], @@ -70,7 +70,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("Slovo"), - album_lib_id: AlbumLibId::Some(7), + album_lib_id: AlbumLibId::Value(7), track_number: 5, track_title: String::from("Zakliatie"), track_artist: vec![String::from("Аркона")], @@ -84,7 +84,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("Slovo"), - album_lib_id: AlbumLibId::Some(7), + album_lib_id: AlbumLibId::Value(7), track_number: 6, track_title: String::from("Predok"), track_artist: vec![String::from("Аркона")], @@ -98,7 +98,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("Slovo"), - album_lib_id: AlbumLibId::Some(7), + album_lib_id: AlbumLibId::Value(7), track_number: 7, track_title: String::from("Nikogda"), track_artist: vec![String::from("Аркона")], @@ -112,7 +112,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("Slovo"), - album_lib_id: AlbumLibId::Some(7), + album_lib_id: AlbumLibId::Value(7), track_number: 8, track_title: String::from("Tam za tumanami"), track_artist: vec![String::from("Аркона")], @@ -126,7 +126,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("Slovo"), - album_lib_id: AlbumLibId::Some(7), + album_lib_id: AlbumLibId::Value(7), track_number: 9, track_title: String::from("Potomok"), track_artist: vec![String::from("Аркона")], @@ -140,7 +140,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("Slovo"), - album_lib_id: AlbumLibId::Some(7), + album_lib_id: AlbumLibId::Value(7), track_number: 10, track_title: String::from("Slovo"), track_artist: vec![String::from("Аркона")], @@ -154,7 +154,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("Slovo"), - album_lib_id: AlbumLibId::Some(7), + album_lib_id: AlbumLibId::Value(7), track_number: 11, track_title: String::from("Odna"), track_artist: vec![String::from("Аркона")], @@ -168,7 +168,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("Slovo"), - album_lib_id: AlbumLibId::Some(7), + album_lib_id: AlbumLibId::Value(7), track_number: 12, track_title: String::from("Vo moiom sadochke…"), track_artist: vec![String::from("Аркона")], @@ -182,7 +182,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("Slovo"), - album_lib_id: AlbumLibId::Some(7), + album_lib_id: AlbumLibId::Value(7), track_number: 13, track_title: String::from("Stenka na stenku"), track_artist: vec![String::from("Аркона")], @@ -196,7 +196,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("Slovo"), - album_lib_id: AlbumLibId::Some(7), + album_lib_id: AlbumLibId::Value(7), track_number: 14, track_title: String::from("Zimushka"), track_artist: vec![String::from("Аркона")], @@ -210,7 +210,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("Vên [re‐recorded]"), - album_lib_id: AlbumLibId::Some(1), + album_lib_id: AlbumLibId::Value(1), track_number: 1, track_title: String::from("Verja Urit an Bitus"), track_artist: vec![String::from("Eluveitie")], @@ -224,7 +224,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("Vên [re‐recorded]"), - album_lib_id: AlbumLibId::Some(1), + album_lib_id: AlbumLibId::Value(1), track_number: 2, track_title: String::from("Uis Elveti"), track_artist: vec![String::from("Eluveitie")], @@ -238,7 +238,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("Vên [re‐recorded]"), - album_lib_id: AlbumLibId::Some(1), + album_lib_id: AlbumLibId::Value(1), track_number: 3, track_title: String::from("Ôrô"), track_artist: vec![String::from("Eluveitie")], @@ -252,7 +252,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("Vên [re‐recorded]"), - album_lib_id: AlbumLibId::Some(1), + album_lib_id: AlbumLibId::Value(1), track_number: 4, track_title: String::from("Lament"), track_artist: vec![String::from("Eluveitie")], @@ -266,7 +266,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("Vên [re‐recorded]"), - album_lib_id: AlbumLibId::Some(1), + album_lib_id: AlbumLibId::Value(1), track_number: 5, track_title: String::from("Druid"), track_artist: vec![String::from("Eluveitie")], @@ -280,7 +280,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("Vên [re‐recorded]"), - album_lib_id: AlbumLibId::Some(1), + album_lib_id: AlbumLibId::Value(1), track_number: 6, track_title: String::from("Jêzaïg"), track_artist: vec![String::from("Eluveitie")], @@ -294,7 +294,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("Slania"), - album_lib_id: AlbumLibId::Some(2), + album_lib_id: AlbumLibId::Value(2), track_number: 1, track_title: String::from("Samon"), track_artist: vec![String::from("Eluveitie")], @@ -308,7 +308,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("Slania"), - album_lib_id: AlbumLibId::Some(2), + album_lib_id: AlbumLibId::Value(2), track_number: 2, track_title: String::from("Primordial Breath"), track_artist: vec![String::from("Eluveitie")], @@ -322,7 +322,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("Slania"), - album_lib_id: AlbumLibId::Some(2), + album_lib_id: AlbumLibId::Value(2), track_number: 3, track_title: String::from("Inis Mona"), track_artist: vec![String::from("Eluveitie")], @@ -336,7 +336,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("Slania"), - album_lib_id: AlbumLibId::Some(2), + album_lib_id: AlbumLibId::Value(2), track_number: 4, track_title: String::from("Gray Sublime Archon"), track_artist: vec![String::from("Eluveitie")], @@ -350,7 +350,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("Slania"), - album_lib_id: AlbumLibId::Some(2), + album_lib_id: AlbumLibId::Value(2), track_number: 5, track_title: String::from("Anagantios"), track_artist: vec![String::from("Eluveitie")], @@ -364,7 +364,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("Slania"), - album_lib_id: AlbumLibId::Some(2), + album_lib_id: AlbumLibId::Value(2), track_number: 6, track_title: String::from("Bloodstained Ground"), track_artist: vec![String::from("Eluveitie")], @@ -378,7 +378,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("Slania"), - album_lib_id: AlbumLibId::Some(2), + album_lib_id: AlbumLibId::Value(2), track_number: 7, track_title: String::from("The Somber Lay"), track_artist: vec![String::from("Eluveitie")], @@ -392,7 +392,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("Slania"), - album_lib_id: AlbumLibId::Some(2), + album_lib_id: AlbumLibId::Value(2), track_number: 8, track_title: String::from("Slanias Song"), track_artist: vec![String::from("Eluveitie")], @@ -406,7 +406,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("Slania"), - album_lib_id: AlbumLibId::Some(2), + album_lib_id: AlbumLibId::Value(2), track_number: 9, track_title: String::from("Giamonios"), track_artist: vec![String::from("Eluveitie")], @@ -420,7 +420,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("Slania"), - album_lib_id: AlbumLibId::Some(2), + album_lib_id: AlbumLibId::Value(2), track_number: 10, track_title: String::from("Tarvos"), track_artist: vec![String::from("Eluveitie")], @@ -434,7 +434,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("Slania"), - album_lib_id: AlbumLibId::Some(2), + album_lib_id: AlbumLibId::Value(2), track_number: 11, track_title: String::from("Calling the Rain"), track_artist: vec![String::from("Eluveitie")], @@ -448,7 +448,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("Slania"), - album_lib_id: AlbumLibId::Some(2), + album_lib_id: AlbumLibId::Value(2), track_number: 12, track_title: String::from("Elembivos"), track_artist: vec![String::from("Eluveitie")], @@ -462,7 +462,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("…nasze jest królestwo, potęga i chwała na wieki…"), - album_lib_id: AlbumLibId::Some(3), + album_lib_id: AlbumLibId::Value(3), track_number: 1, track_title: String::from("Intro = Chaos"), track_artist: vec![String::from("Frontside")], @@ -476,7 +476,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("…nasze jest królestwo, potęga i chwała na wieki…"), - album_lib_id: AlbumLibId::Some(3), + album_lib_id: AlbumLibId::Value(3), track_number: 2, track_title: String::from("Modlitwa"), track_artist: vec![String::from("Frontside")], @@ -490,7 +490,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("…nasze jest królestwo, potęga i chwała na wieki…"), - album_lib_id: AlbumLibId::Some(3), + album_lib_id: AlbumLibId::Value(3), track_number: 3, track_title: String::from("Długa droga z piekła"), track_artist: vec![String::from("Frontside")], @@ -504,7 +504,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("…nasze jest królestwo, potęga i chwała na wieki…"), - album_lib_id: AlbumLibId::Some(3), + album_lib_id: AlbumLibId::Value(3), track_number: 4, track_title: String::from("Synowie ognia"), track_artist: vec![String::from("Frontside")], @@ -518,7 +518,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("…nasze jest królestwo, potęga i chwała na wieki…"), - album_lib_id: AlbumLibId::Some(3), + album_lib_id: AlbumLibId::Value(3), track_number: 5, track_title: String::from("1902"), track_artist: vec![String::from("Frontside")], @@ -532,7 +532,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("…nasze jest królestwo, potęga i chwała na wieki…"), - album_lib_id: AlbumLibId::Some(3), + album_lib_id: AlbumLibId::Value(3), track_number: 6, track_title: String::from("Krew za krew"), track_artist: vec![String::from("Frontside")], @@ -546,7 +546,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("…nasze jest królestwo, potęga i chwała na wieki…"), - album_lib_id: AlbumLibId::Some(3), + album_lib_id: AlbumLibId::Value(3), track_number: 7, track_title: String::from("Kulminacja"), track_artist: vec![String::from("Frontside")], @@ -560,7 +560,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("…nasze jest królestwo, potęga i chwała na wieki…"), - album_lib_id: AlbumLibId::Some(3), + album_lib_id: AlbumLibId::Value(3), track_number: 8, track_title: String::from("Judasz"), track_artist: vec![String::from("Frontside")], @@ -574,7 +574,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("…nasze jest królestwo, potęga i chwała na wieki…"), - album_lib_id: AlbumLibId::Some(3), + album_lib_id: AlbumLibId::Value(3), track_number: 9, track_title: String::from("Więzy"), track_artist: vec![String::from("Frontside")], @@ -588,7 +588,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("…nasze jest królestwo, potęga i chwała na wieki…"), - album_lib_id: AlbumLibId::Some(3), + album_lib_id: AlbumLibId::Value(3), track_number: 10, track_title: String::from("Zagubione dusze"), track_artist: vec![String::from("Frontside")], @@ -602,7 +602,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("…nasze jest królestwo, potęga i chwała na wieki…"), - album_lib_id: AlbumLibId::Some(3), + album_lib_id: AlbumLibId::Value(3), track_number: 11, track_title: String::from("Linia życia"), track_artist: vec![String::from("Frontside")], @@ -630,7 +630,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("Unbreakable"), - album_lib_id: AlbumLibId::Some(4), + album_lib_id: AlbumLibId::Value(4), track_number: 1, track_title: String::from("Unbreakable"), track_artist: vec![String::from("Heaven’s Basement")], @@ -644,7 +644,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("Unbreakable"), - album_lib_id: AlbumLibId::Some(4), + album_lib_id: AlbumLibId::Value(4), track_number: 2, track_title: String::from("Guilt Trips and Sins"), track_artist: vec![String::from("Heaven’s Basement")], @@ -658,7 +658,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("Unbreakable"), - album_lib_id: AlbumLibId::Some(4), + album_lib_id: AlbumLibId::Value(4), track_number: 3, track_title: String::from("The Long Goodbye"), track_artist: vec![String::from("Heaven’s Basement")], @@ -672,7 +672,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("Unbreakable"), - album_lib_id: AlbumLibId::Some(4), + album_lib_id: AlbumLibId::Value(4), track_number: 4, track_title: String::from("Close Encounters"), track_artist: vec![String::from("Heaven’s Basement")], @@ -686,7 +686,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("Unbreakable"), - album_lib_id: AlbumLibId::Some(4), + album_lib_id: AlbumLibId::Value(4), track_number: 5, track_title: String::from("Paranoia"), track_artist: vec![String::from("Heaven’s Basement")], @@ -700,7 +700,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("Unbreakable"), - album_lib_id: AlbumLibId::Some(4), + album_lib_id: AlbumLibId::Value(4), track_number: 6, track_title: String::from("Let Me Out of Here"), track_artist: vec![String::from("Heaven’s Basement")], @@ -714,7 +714,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("Unbreakable"), - album_lib_id: AlbumLibId::Some(4), + album_lib_id: AlbumLibId::Value(4), track_number: 7, track_title: String::from("Leeches"), track_artist: vec![String::from("Heaven’s Basement")], @@ -728,7 +728,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("Ride the Lightning"), - album_lib_id: AlbumLibId::Some(5), + album_lib_id: AlbumLibId::Value(5), track_number: 1, track_title: String::from("Fight Fire with Fire"), track_artist: vec![String::from("Metallica")], @@ -742,7 +742,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("Ride the Lightning"), - album_lib_id: AlbumLibId::Some(5), + album_lib_id: AlbumLibId::Value(5), track_number: 2, track_title: String::from("Ride the Lightning"), track_artist: vec![String::from("Metallica")], @@ -756,7 +756,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("Ride the Lightning"), - album_lib_id: AlbumLibId::Some(5), + album_lib_id: AlbumLibId::Value(5), track_number: 3, track_title: String::from("For Whom the Bell Tolls"), track_artist: vec![String::from("Metallica")], @@ -770,7 +770,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("Ride the Lightning"), - album_lib_id: AlbumLibId::Some(5), + album_lib_id: AlbumLibId::Value(5), track_number: 4, track_title: String::from("Fade to Black"), track_artist: vec![String::from("Metallica")], @@ -784,7 +784,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("Ride the Lightning"), - album_lib_id: AlbumLibId::Some(5), + album_lib_id: AlbumLibId::Value(5), track_number: 5, track_title: String::from("Trapped under Ice"), track_artist: vec![String::from("Metallica")], @@ -798,7 +798,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("Ride the Lightning"), - album_lib_id: AlbumLibId::Some(5), + album_lib_id: AlbumLibId::Value(5), track_number: 6, track_title: String::from("Escape"), track_artist: vec![String::from("Metallica")], @@ -812,7 +812,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("Ride the Lightning"), - album_lib_id: AlbumLibId::Some(5), + album_lib_id: AlbumLibId::Value(5), track_number: 7, track_title: String::from("Creeping Death"), track_artist: vec![String::from("Metallica")], @@ -826,7 +826,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("Ride the Lightning"), - album_lib_id: AlbumLibId::Some(5), + album_lib_id: AlbumLibId::Value(5), track_number: 8, track_title: String::from("The Call of Ktulu"), track_artist: vec![String::from("Metallica")], @@ -840,7 +840,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("S&M"), - album_lib_id: AlbumLibId::Some(6), + album_lib_id: AlbumLibId::Value(6), track_number: 1, track_title: String::from("The Ecstasy of Gold"), track_artist: vec![String::from("Metallica")], @@ -854,7 +854,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("S&M"), - album_lib_id: AlbumLibId::Some(6), + album_lib_id: AlbumLibId::Value(6), track_number: 2, track_title: String::from("The Call of Ktulu"), track_artist: vec![String::from("Metallica")], @@ -868,7 +868,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("S&M"), - album_lib_id: AlbumLibId::Some(6), + album_lib_id: AlbumLibId::Value(6), track_number: 3, track_title: String::from("Master of Puppets"), track_artist: vec![String::from("Metallica")], @@ -882,7 +882,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("S&M"), - album_lib_id: AlbumLibId::Some(6), + album_lib_id: AlbumLibId::Value(6), track_number: 4, track_title: String::from("Of Wolf and Man"), track_artist: vec![String::from("Metallica")], @@ -896,7 +896,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("S&M"), - album_lib_id: AlbumLibId::Some(6), + album_lib_id: AlbumLibId::Value(6), track_number: 5, track_title: String::from("The Thing That Should Not Be"), track_artist: vec![String::from("Metallica")], @@ -910,7 +910,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("S&M"), - album_lib_id: AlbumLibId::Some(6), + album_lib_id: AlbumLibId::Value(6), track_number: 6, track_title: String::from("Fuel"), track_artist: vec![String::from("Metallica")], @@ -924,7 +924,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("S&M"), - album_lib_id: AlbumLibId::Some(6), + album_lib_id: AlbumLibId::Value(6), track_number: 7, track_title: String::from("The Memory Remains"), track_artist: vec![String::from("Metallica")], @@ -938,7 +938,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("S&M"), - album_lib_id: AlbumLibId::Some(6), + album_lib_id: AlbumLibId::Value(6), track_number: 8, track_title: String::from("No Leaf Clover"), track_artist: vec![String::from("Metallica")], @@ -952,7 +952,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("S&M"), - album_lib_id: AlbumLibId::Some(6), + album_lib_id: AlbumLibId::Value(6), track_number: 9, track_title: String::from("Hero of the Day"), track_artist: vec![String::from("Metallica")], @@ -966,7 +966,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("S&M"), - album_lib_id: AlbumLibId::Some(6), + album_lib_id: AlbumLibId::Value(6), track_number: 10, track_title: String::from("Devil’s Dance"), track_artist: vec![String::from("Metallica")], @@ -980,7 +980,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("S&M"), - album_lib_id: AlbumLibId::Some(6), + album_lib_id: AlbumLibId::Value(6), track_number: 11, track_title: String::from("Bleeding Me"), track_artist: vec![String::from("Metallica")], @@ -994,7 +994,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("S&M"), - album_lib_id: AlbumLibId::Some(6), + album_lib_id: AlbumLibId::Value(6), track_number: 12, track_title: String::from("Nothing Else Matters"), track_artist: vec![String::from("Metallica")], @@ -1008,7 +1008,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("S&M"), - album_lib_id: AlbumLibId::Some(6), + album_lib_id: AlbumLibId::Value(6), track_number: 13, track_title: String::from("Until It Sleeps"), track_artist: vec![String::from("Metallica")], @@ -1022,7 +1022,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("S&M"), - album_lib_id: AlbumLibId::Some(6), + album_lib_id: AlbumLibId::Value(6), track_number: 14, track_title: String::from("For Whom the Bell Tolls"), track_artist: vec![String::from("Metallica")], @@ -1036,7 +1036,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("S&M"), - album_lib_id: AlbumLibId::Some(6), + album_lib_id: AlbumLibId::Value(6), track_number: 15, track_title: String::from("−Human"), track_artist: vec![String::from("Metallica")], @@ -1050,7 +1050,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("S&M"), - album_lib_id: AlbumLibId::Some(6), + album_lib_id: AlbumLibId::Value(6), track_number: 16, track_title: String::from("Wherever I May Roam"), track_artist: vec![String::from("Metallica")], @@ -1064,7 +1064,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("S&M"), - album_lib_id: AlbumLibId::Some(6), + album_lib_id: AlbumLibId::Value(6), track_number: 17, track_title: String::from("Outlaw Torn"), track_artist: vec![String::from("Metallica")], @@ -1078,7 +1078,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("S&M"), - album_lib_id: AlbumLibId::Some(6), + album_lib_id: AlbumLibId::Value(6), track_number: 18, track_title: String::from("Sad but True"), track_artist: vec![String::from("Metallica")], @@ -1092,7 +1092,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("S&M"), - album_lib_id: AlbumLibId::Some(6), + album_lib_id: AlbumLibId::Value(6), track_number: 19, track_title: String::from("One"), track_artist: vec![String::from("Metallica")], @@ -1106,7 +1106,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("S&M"), - album_lib_id: AlbumLibId::Some(6), + album_lib_id: AlbumLibId::Value(6), track_number: 20, track_title: String::from("Enter Sandman"), track_artist: vec![String::from("Metallica")], @@ -1120,7 +1120,7 @@ pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| -> Vec { album_month: 0, album_day: 0, album_title: String::from("S&M"), - album_lib_id: AlbumLibId::Some(6), + album_lib_id: AlbumLibId::Value(6), track_number: 21, track_title: String::from("Battery"), track_artist: vec![String::from("Metallica")], diff --git a/tests/testlib.rs b/tests/testlib.rs index 170c53f..072b325 100644 --- a/tests/testlib.rs +++ b/tests/testlib.rs @@ -41,7 +41,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { meta: AlbumMeta { id: AlbumId { title: String::from("Slovo"), - lib_id: AlbumLibId::Some(7), + lib_id: AlbumLibId::Value(7), }, date: 2011.into(), seq: AlbumSeq(0), @@ -234,7 +234,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { meta: AlbumMeta { id: AlbumId { title: String::from("Vên [re‐recorded]"), - lib_id: AlbumLibId::Some(1), + lib_id: AlbumLibId::Value(1), }, date: 2004.into(), seq: AlbumSeq(0), @@ -317,7 +317,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { meta: AlbumMeta { id: AlbumId { title: String::from("Slania"), - lib_id: AlbumLibId::Some(2), + lib_id: AlbumLibId::Value(2), }, date: 2008.into(), seq: AlbumSeq(0), @@ -488,7 +488,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { meta: AlbumMeta { id: AlbumId { title: String::from("…nasze jest królestwo, potęga i chwała na wieki…"), - lib_id: AlbumLibId::Some(3), + lib_id: AlbumLibId::Value(3), }, date: 2001.into(), seq: AlbumSeq(0), @@ -670,7 +670,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { meta: AlbumMeta { id: AlbumId { title: String::from("Unbreakable"), - lib_id: AlbumLibId::Some(4), + lib_id: AlbumLibId::Value(4), }, date: 2011.into(), seq: AlbumSeq(0), @@ -786,7 +786,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { meta: AlbumMeta { id: AlbumId { title: String::from("Ride the Lightning"), - lib_id: AlbumLibId::Some(5), + lib_id: AlbumLibId::Value(5), }, date: 1984.into(), seq: AlbumSeq(0), @@ -891,7 +891,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { meta: AlbumMeta { id: AlbumId { title: String::from("S&M"), - lib_id: AlbumLibId::Some(6), + lib_id: AlbumLibId::Value(6), }, date: 1999.into(), seq: AlbumSeq(0),