diff --git a/src/core/collection/album.rs b/src/core/collection/album.rs index 0bb0161..b4c8c66 100644 --- a/src/core/collection/album.rs +++ b/src/core/collection/album.rs @@ -352,11 +352,11 @@ mod tests { let date: AlbumDate = (2024, 3, 2).into(); let album_id_1 = AlbumId::new("album z"); - let mut album_1 = Album::new(album_id_1).with_date(date.clone()); + let mut album_1 = Album::new(album_id_1).with_date(date); album_1.meta.set_seq(AlbumSeq(1)); let album_id_2 = AlbumId::new("album a"); - let mut album_2 = Album::new(album_id_2).with_date(date.clone()); + let mut album_2 = Album::new(album_id_2).with_date(date); album_2.meta.set_seq(AlbumSeq(2)); assert_ne!(album_1, album_2); diff --git a/src/external/database/json/mod.rs b/src/external/database/json/mod.rs index 126a4bd..0b7edf9 100644 --- a/src/external/database/json/mod.rs +++ b/src/external/database/json/mod.rs @@ -73,7 +73,7 @@ mod tests { use mockall::predicate; use crate::core::{ - collection::{album::AlbumDate, artist::Artist, Collection}, + collection::{artist::Artist, Collection}, testmod::FULL_COLLECTION, }; @@ -84,7 +84,6 @@ mod tests { let mut expected = FULL_COLLECTION.to_owned(); for artist in expected.iter_mut() { for album in artist.albums.iter_mut() { - album.meta.date = AlbumDate::default(); album.tracks.clear(); } } diff --git a/src/external/database/json/testmod.rs b/src/external/database/json/testmod.rs index 0f2f602..04fd2b1 100644 --- a/src/external/database/json/testmod.rs +++ b/src/external/database/json/testmod.rs @@ -1,5 +1,5 @@ pub static DATABASE_JSON: &str = "{\ - \"V20250101\":\ + \"V20250103\":\ [\ {\ \"name\":\"Album_Artist ‘A’\",\ @@ -11,12 +11,15 @@ pub static DATABASE_JSON: &str = "{\ },\ \"albums\":[\ {\ - \"title\":\"album_title a.a\",\"lib_id\":{\"Value\":1},\"seq\":1,\ + \"title\":\"album_title a.a\",\"lib_id\":{\"Value\":1},\ + \"date\":{\"year\":1998,\"month\":null,\"day\":null},\"seq\":1,\ \"musicbrainz\":{\"Some\":\"00000000-0000-0000-0000-000000000000\"},\ \"primary_type\":\"Album\",\"secondary_types\":[]\ },\ {\ - \"title\":\"album_title a.b\",\"lib_id\":{\"Value\":2},\"seq\":1,\"musicbrainz\":\"None\",\ + \"title\":\"album_title a.b\",\"lib_id\":{\"Value\":2},\ + \"date\":{\"year\":2015,\"month\":4,\"day\":null},\"seq\":1,\ + \"musicbrainz\":\"None\",\ \"primary_type\":\"Album\",\"secondary_types\":[]\ }\ ]\ @@ -35,21 +38,27 @@ pub static DATABASE_JSON: &str = "{\ },\ \"albums\":[\ {\ - \"title\":\"album_title b.a\",\"lib_id\":{\"Value\":3},\"seq\":1,\"musicbrainz\":\"None\",\ + \"title\":\"album_title b.a\",\"lib_id\":{\"Value\":3},\ + \"date\":{\"year\":2003,\"month\":6,\"day\":6},\"seq\":1,\ + \"musicbrainz\":\"None\",\ \"primary_type\":\"Album\",\"secondary_types\":[]\ },\ {\ - \"title\":\"album_title b.b\",\"lib_id\":{\"Value\":4},\"seq\":3,\ + \"title\":\"album_title b.b\",\"lib_id\":{\"Value\":4},\ + \"date\":{\"year\":2008,\"month\":null,\"day\":null},\"seq\":3,\ \"musicbrainz\":{\"Some\":\"11111111-1111-1111-1111-111111111111\"},\ \"primary_type\":\"Album\",\"secondary_types\":[]\ },\ {\ - \"title\":\"album_title b.c\",\"lib_id\":{\"Value\":5},\"seq\":2,\ + \"title\":\"album_title b.c\",\"lib_id\":{\"Value\":5},\ + \"date\":{\"year\":2009,\"month\":null,\"day\":null},\"seq\":2,\ \"musicbrainz\":{\"Some\":\"11111111-1111-1111-1111-111111111112\"},\ \"primary_type\":\"Album\",\"secondary_types\":[]\ },\ {\ - \"title\":\"album_title b.d\",\"lib_id\":{\"Value\":6},\"seq\":4,\"musicbrainz\":\"None\",\ + \"title\":\"album_title b.d\",\"lib_id\":{\"Value\":6},\ + \"date\":{\"year\":2015,\"month\":null,\"day\":null},\"seq\":4,\ + \"musicbrainz\":\"None\",\ \"primary_type\":\"Album\",\"secondary_types\":[]\ }\ ]\ @@ -61,11 +70,15 @@ pub static DATABASE_JSON: &str = "{\ \"properties\":{},\ \"albums\":[\ {\ - \"title\":\"album_title c.a\",\"lib_id\":{\"Value\":7},\"seq\":0,\"musicbrainz\":\"None\",\ + \"title\":\"album_title c.a\",\"lib_id\":{\"Value\":7},\ + \"date\":{\"year\":1985,\"month\":null,\"day\":null},\"seq\":0,\ + \"musicbrainz\":\"None\",\ \"primary_type\":\"Album\",\"secondary_types\":[]\ },\ {\ - \"title\":\"album_title c.b\",\"lib_id\":{\"Value\":8},\"seq\":0,\"musicbrainz\":\"None\",\ + \"title\":\"album_title c.b\",\"lib_id\":{\"Value\":8},\ + \"date\":{\"year\":2018,\"month\":null,\"day\":null},\"seq\":0,\ + \"musicbrainz\":\"None\",\ \"primary_type\":\"Album\",\"secondary_types\":[]\ }\ ]\ @@ -77,11 +90,15 @@ pub static DATABASE_JSON: &str = "{\ \"properties\":{},\ \"albums\":[\ {\ - \"title\":\"album_title d.a\",\"lib_id\":{\"Value\":9},\"seq\":0,\"musicbrainz\":\"None\",\ + \"title\":\"album_title d.a\",\"lib_id\":{\"Value\":9},\ + \"date\":{\"year\":1995,\"month\":null,\"day\":null},\"seq\":0,\ + \"musicbrainz\":\"None\",\ \"primary_type\":\"Album\",\"secondary_types\":[]\ },\ {\ - \"title\":\"album_title d.b\",\"lib_id\":{\"Value\":10},\"seq\":0,\"musicbrainz\":\"None\",\ + \"title\":\"album_title d.b\",\"lib_id\":{\"Value\":10},\ + \"date\":{\"year\":2028,\"month\":null,\"day\":null},\"seq\":0,\ + \"musicbrainz\":\"None\",\ \"primary_type\":\"Album\",\"secondary_types\":[]\ }\ ]\ diff --git a/tests/database/json.rs b/tests/database/json.rs index 2ee6755..da96d9e 100644 --- a/tests/database/json.rs +++ b/tests/database/json.rs @@ -4,7 +4,7 @@ use once_cell::sync::Lazy; use tempfile::NamedTempFile; use musichoard::{ - collection::{album::AlbumDate, artist::Artist, Collection}, + collection::{artist::Artist, Collection}, external::database::json::{backend::JsonDatabaseFileBackend, JsonDatabase}, interface::database::IDatabase, }; @@ -18,7 +18,6 @@ fn expected() -> Collection { let mut expected = COLLECTION.to_owned(); for artist in expected.iter_mut() { for album in artist.albums.iter_mut() { - album.meta.date = AlbumDate::default(); album.tracks.clear(); } } diff --git a/tests/files/database/database.json b/tests/files/database/database.json index 93fb18a..ccce86d 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":{"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 +{"V20250103":[{"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},"date":{"year":2011,"month":null,"day":null},"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},"date":{"year":2004,"month":null,"day":null},"seq":0,"musicbrainz":"None","primary_type":"Ep","secondary_types":[]},{"title":"Slania","lib_id":{"Value":2},"date":{"year":2008,"month":null,"day":null},"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},"date":{"year":2001,"month":null,"day":null},"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","date":{"year":2011,"month":null,"day":null},"seq":0,"musicbrainz":"None","primary_type":null,"secondary_types":[]},{"title":"Unbreakable","lib_id":{"Value":4},"date":{"year":2011,"month":null,"day":null},"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},"date":{"year":1984,"month":null,"day":null},"seq":0,"musicbrainz":"None","primary_type":"Album","secondary_types":[]},{"title":"S&M","lib_id":{"Value":6},"date":{"year":1999,"month":null,"day":null},"seq":0,"musicbrainz":"None","primary_type":"Album","secondary_types":["Live"]}]}]} \ No newline at end of file