diff --git a/src/database/json/mod.rs b/src/database/json/mod.rs index 3bf0015..9dff3c8 100644 --- a/src/database/json/mod.rs +++ b/src/database/json/mod.rs @@ -66,7 +66,7 @@ mod tests { use mockall::predicate; - use crate::{testlib::FULL_COLLECTION, Artist, ArtistId, Collection}; + use crate::{musichoard::testmod::FULL_COLLECTION, Artist, ArtistId, Collection}; use super::*; use testmod::DATABASE_JSON; diff --git a/src/lib.rs b/src/lib.rs index 2ec5afb..c1d1906 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -22,6 +22,7 @@ pub use collection::{ // FIXME: validate the re-exports pub use musichoard::{MusicHoard, MusicHoardBuilder, NoDatabase, NoLibrary}; +// FIXME: this should be in the musichoard module. /// Error type for `musichoard`. #[derive(Debug, PartialEq, Eq)] pub enum Error { @@ -89,7 +90,4 @@ impl From for Error { #[cfg(test)] #[macro_use] -mod testmacros; - -#[cfg(test)] -mod testlib; +mod tests; diff --git a/src/main.rs b/src/main.rs index ce20e33..40ef42d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -128,7 +128,4 @@ fn main() { #[cfg(test)] #[macro_use] -mod testmacros; - -#[cfg(test)] -mod testbin; +mod tests; diff --git a/src/musichoard/mod.rs b/src/musichoard/mod.rs index 549ee02..9c5251b 100644 --- a/src/musichoard/mod.rs +++ b/src/musichoard/mod.rs @@ -372,5 +372,8 @@ impl MusicHoardBuilder { } } +#[cfg(test)] +pub mod testmod; + #[cfg(test)] mod tests; diff --git a/src/testlib.rs b/src/musichoard/testmod.rs similarity index 94% rename from src/testlib.rs rename to src/musichoard/testmod.rs index 519757d..6df9f36 100644 --- a/src/testlib.rs +++ b/src/musichoard/testmod.rs @@ -5,5 +5,7 @@ use crate::collection::{ }; use once_cell::sync::Lazy; +use crate::tests::*; + pub static LIBRARY_COLLECTION: Lazy> = Lazy::new(|| library_collection!()); pub static FULL_COLLECTION: Lazy> = Lazy::new(|| full_collection!()); diff --git a/src/musichoard/tests.rs b/src/musichoard/tests.rs index 809f492..c9a646c 100644 --- a/src/musichoard/tests.rs +++ b/src/musichoard/tests.rs @@ -2,6 +2,8 @@ use mockall::predicate; use super::*; +use super::testmod::{FULL_COLLECTION, LIBRARY_COLLECTION}; + // FIXME: check all crate::* imports - are the tests where they should be? use crate::collection::{ artist::{ArtistProperties, Bandcamp, MusicBrainz, MusicButler, Qobuz}, @@ -10,7 +12,6 @@ use crate::collection::{ }; use crate::database::{self, MockIDatabase}; use crate::library::{self, testmod::LIBRARY_ITEMS, MockILibrary}; -use crate::testlib::{FULL_COLLECTION, LIBRARY_COLLECTION}; static MUSICBRAINZ: &str = "https://musicbrainz.org/artist/d368baa8-21ca-4759-9731-0b2753071ad8"; static MUSICBRAINZ_2: &str = "https://musicbrainz.org/artist/823869a5-5ded-4f6b-9fb7-2a9344d83c6b"; diff --git a/src/testmacros.rs b/src/tests.rs similarity index 99% rename from src/testmacros.rs rename to src/tests.rs index 0aab77d..84b1372 100644 --- a/src/testmacros.rs +++ b/src/tests.rs @@ -321,3 +321,6 @@ macro_rules! full_collection { collection }}; } + +pub(crate) use full_collection; +pub(crate) use library_collection; diff --git a/src/tui/mod.rs b/src/tui/mod.rs index 4ccbe29..91c7e1a 100644 --- a/src/tui/mod.rs +++ b/src/tui/mod.rs @@ -157,6 +157,9 @@ impl Tui { // GRCOV_EXCL_STOP } +#[cfg(test)] +mod testmod; + #[cfg(test)] mod tests { use std::{io, thread}; @@ -164,7 +167,7 @@ mod tests { use musichoard::Collection; use ratatui::{backend::TestBackend, Terminal}; - use crate::testbin::COLLECTION; + use super::testmod::COLLECTION; use super::{ event::EventError, diff --git a/src/testbin.rs b/src/tui/testmod.rs similarity index 92% rename from src/testbin.rs rename to src/tui/testmod.rs index 541464a..a5c7221 100644 --- a/src/testbin.rs +++ b/src/tui/testmod.rs @@ -4,4 +4,6 @@ use musichoard::{ }; use once_cell::sync::Lazy; +use crate::tests::*; + pub static COLLECTION: Lazy> = Lazy::new(|| full_collection!()); diff --git a/src/tui/ui.rs b/src/tui/ui.rs index 091297a..3319068 100644 --- a/src/tui/ui.rs +++ b/src/tui/ui.rs @@ -733,8 +733,8 @@ impl IUi for Ui { #[cfg(test)] mod tests { - use crate::testbin::COLLECTION; use crate::tui::lib::MockIMusicHoard; + use crate::tui::testmod::COLLECTION; use crate::tui::tests::{terminal, ui}; use super::*;