diff --git a/src/database/json/mod.rs b/src/database/json/mod.rs index b4abd8b..3d47c9f 100644 --- a/src/database/json/mod.rs +++ b/src/database/json/mod.rs @@ -57,17 +57,19 @@ impl IDatabase for JsonDatabase { } } +#[cfg(test)] +pub mod testlib; + #[cfg(test)] mod tests { use std::collections::HashMap; use mockall::predicate; - use super::*; + use crate::{testlib::FULL_COLLECTION, Artist, ArtistId, Collection}; - use crate::{ - database::testlib::DATABASE_JSON, testlib::FULL_COLLECTION, Artist, ArtistId, Collection, - }; + use super::*; + use testlib::DATABASE_JSON; #[test] fn save() { diff --git a/src/database/testlib.rs b/src/database/json/testlib.rs similarity index 100% rename from src/database/testlib.rs rename to src/database/json/testlib.rs diff --git a/src/database/mod.rs b/src/database/mod.rs index 248019f..c23aabc 100644 --- a/src/database/mod.rs +++ b/src/database/mod.rs @@ -85,9 +85,6 @@ impl From for SaveError { } } -#[cfg(test)] -pub mod testlib; - #[cfg(test)] mod tests { use std::io; diff --git a/src/library/beets/mod.rs b/src/library/beets/mod.rs index 5a19559..e344d0b 100644 --- a/src/library/beets/mod.rs +++ b/src/library/beets/mod.rs @@ -169,13 +169,17 @@ impl ILibraryPrivate for BeetsLibrary { } } +#[cfg(test)] +mod testlib; + #[cfg(test)] mod tests { use mockall::predicate; - use crate::library::testlib::{LIBRARY_BEETS, LIBRARY_ITEMS}; + use crate::library::testlib::LIBRARY_ITEMS; use super::*; + use testlib::LIBRARY_BEETS; #[test] fn test_query() { diff --git a/src/library/beets/testlib.rs b/src/library/beets/testlib.rs new file mode 100644 index 0000000..583d8e2 --- /dev/null +++ b/src/library/beets/testlib.rs @@ -0,0 +1,23 @@ +use once_cell::sync::Lazy; + +macro_rules! library_beets { + () => { + vec![ + String::from("album_artist a -*^- -*^- 1998 -*^- album_title a.a -*^- 1 -*^- track a.a.1 -*^- artist a.a.1 -*^- FLAC -*^- 992"), + String::from("album_artist a -*^- -*^- 1998 -*^- album_title a.a -*^- 2 -*^- track a.a.2 -*^- artist a.a.2.1; artist a.a.2.2 -*^- MP3 -*^- 320"), + String::from("album_artist a -*^- -*^- 1998 -*^- album_title a.a -*^- 3 -*^- track a.a.3 -*^- artist a.a.3 -*^- FLAC -*^- 1061"), + String::from("album_artist a -*^- -*^- 2015 -*^- album_title a.b -*^- 1 -*^- track a.b.1 -*^- artist a.b.1 -*^- FLAC -*^- 1004"), + String::from("album_artist a -*^- -*^- 2015 -*^- album_title a.b -*^- 2 -*^- track a.b.2 -*^- artist a.b.2 -*^- FLAC -*^- 1077"), + String::from("album_artist b -*^- -*^- 2003 -*^- album_title b.a -*^- 1 -*^- track b.a.1 -*^- artist b.a.1 -*^- MP3 -*^- 190"), + String::from("album_artist b -*^- -*^- 2003 -*^- album_title b.a -*^- 2 -*^- track b.a.2 -*^- artist b.a.2.1; artist b.a.2.2 -*^- MP3 -*^- 120"), + String::from("album_artist b -*^- -*^- 2008 -*^- album_title b.b -*^- 1 -*^- track b.b.1 -*^- artist b.b.1 -*^- FLAC -*^- 1077"), + String::from("album_artist b -*^- -*^- 2008 -*^- album_title b.b -*^- 2 -*^- track b.b.2 -*^- artist b.b.2.1; artist b.b.2.2 -*^- MP3 -*^- 320"), + String::from("album_artist c -*^- -*^- 1985 -*^- album_title c.a -*^- 1 -*^- track c.a.1 -*^- artist c.a.1 -*^- MP3 -*^- 320"), + String::from("album_artist c -*^- -*^- 1985 -*^- album_title c.a -*^- 2 -*^- track c.a.2 -*^- artist c.a.2.1; artist c.a.2.2 -*^- MP3 -*^- 120"), + String::from("album_artist c -*^- -*^- 2018 -*^- album_title c.b -*^- 1 -*^- track c.b.1 -*^- artist c.b.1 -*^- FLAC -*^- 1041"), + String::from("album_artist c -*^- -*^- 2018 -*^- album_title c.b -*^- 2 -*^- track c.b.2 -*^- artist c.b.2.1; artist c.b.2.2 -*^- FLAC -*^- 756") + ] + }; +} + +pub static LIBRARY_BEETS: Lazy> = Lazy::new(|| library_beets!()); diff --git a/src/library/testlib.rs b/src/library/testlib.rs index 6bb4ed3..982ffa2 100644 --- a/src/library/testlib.rs +++ b/src/library/testlib.rs @@ -3,26 +3,6 @@ use once_cell::sync::Lazy; use crate::library::Item; use crate::Format; -macro_rules! library_beets { - () => { - vec![ - String::from("album_artist a -*^- -*^- 1998 -*^- album_title a.a -*^- 1 -*^- track a.a.1 -*^- artist a.a.1 -*^- FLAC -*^- 992"), - String::from("album_artist a -*^- -*^- 1998 -*^- album_title a.a -*^- 2 -*^- track a.a.2 -*^- artist a.a.2.1; artist a.a.2.2 -*^- MP3 -*^- 320"), - String::from("album_artist a -*^- -*^- 1998 -*^- album_title a.a -*^- 3 -*^- track a.a.3 -*^- artist a.a.3 -*^- FLAC -*^- 1061"), - String::from("album_artist a -*^- -*^- 2015 -*^- album_title a.b -*^- 1 -*^- track a.b.1 -*^- artist a.b.1 -*^- FLAC -*^- 1004"), - String::from("album_artist a -*^- -*^- 2015 -*^- album_title a.b -*^- 2 -*^- track a.b.2 -*^- artist a.b.2 -*^- FLAC -*^- 1077"), - String::from("album_artist b -*^- -*^- 2003 -*^- album_title b.a -*^- 1 -*^- track b.a.1 -*^- artist b.a.1 -*^- MP3 -*^- 190"), - String::from("album_artist b -*^- -*^- 2003 -*^- album_title b.a -*^- 2 -*^- track b.a.2 -*^- artist b.a.2.1; artist b.a.2.2 -*^- MP3 -*^- 120"), - String::from("album_artist b -*^- -*^- 2008 -*^- album_title b.b -*^- 1 -*^- track b.b.1 -*^- artist b.b.1 -*^- FLAC -*^- 1077"), - String::from("album_artist b -*^- -*^- 2008 -*^- album_title b.b -*^- 2 -*^- track b.b.2 -*^- artist b.b.2.1; artist b.b.2.2 -*^- MP3 -*^- 320"), - String::from("album_artist c -*^- -*^- 1985 -*^- album_title c.a -*^- 1 -*^- track c.a.1 -*^- artist c.a.1 -*^- MP3 -*^- 320"), - String::from("album_artist c -*^- -*^- 1985 -*^- album_title c.a -*^- 2 -*^- track c.a.2 -*^- artist c.a.2.1; artist c.a.2.2 -*^- MP3 -*^- 120"), - String::from("album_artist c -*^- -*^- 2018 -*^- album_title c.b -*^- 1 -*^- track c.b.1 -*^- artist c.b.1 -*^- FLAC -*^- 1041"), - String::from("album_artist c -*^- -*^- 2018 -*^- album_title c.b -*^- 2 -*^- track c.b.2 -*^- artist c.b.2.1; artist c.b.2.2 -*^- FLAC -*^- 756") - ] - }; -} - macro_rules! library_items { () => { vec![ @@ -188,5 +168,4 @@ macro_rules! library_items { }; } -pub static LIBRARY_BEETS: Lazy> = Lazy::new(|| library_beets!()); pub static LIBRARY_ITEMS: Lazy> = Lazy::new(|| library_items!());