From 11ab6dcf38815255e9863dd756b8f604f5d696de Mon Sep 17 00:00:00 2001 From: Joonas Koivunen Date: Fri, 4 Sep 2020 16:42:47 +0300 Subject: [PATCH] refactor: rename tests_for_ds_impl, add doc --- src/repo/common_tests.rs | 6 +++++- src/repo/fs.rs | 2 +- src/repo/mem.rs | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/repo/common_tests.rs b/src/repo/common_tests.rs index a860d8cb2..4e2bf460d 100644 --- a/src/repo/common_tests.rs +++ b/src/repo/common_tests.rs @@ -39,8 +39,12 @@ impl std::ops::Deref for DSTestContext { } } +/// Generates the "common interface" tests for PinStore implementations as a given module using a +/// types factory method. When adding tests, it might be easier to write them against the one +/// implementation and only then move them here; the compiler errors seem to point at the +/// `#[tokio::test]` attribute and the error needs to be guessed. #[macro_export] -macro_rules! tests_for_ds_impl { +macro_rules! pinstore_interface_tests { ($module_name:ident, $factory:expr) => { #[cfg(test)] mod $module_name { diff --git a/src/repo/fs.rs b/src/repo/fs.rs index c3babdc7b..30e14d0ca 100644 --- a/src/repo/fs.rs +++ b/src/repo/fs.rs @@ -86,4 +86,4 @@ impl DataStore for FsDataStore { } #[cfg(test)] -crate::tests_for_ds_impl!(common_tests, crate::repo::fs::FsDataStore::new); +crate::pinstore_interface_tests!(common_tests, crate::repo::fs::FsDataStore::new); diff --git a/src/repo/mem.rs b/src/repo/mem.rs index f2308c3ff..2097bcb1d 100644 --- a/src/repo/mem.rs +++ b/src/repo/mem.rs @@ -649,7 +649,7 @@ pub enum PinUpdateError { } #[cfg(test)] -crate::tests_for_ds_impl!(common_tests, crate::repo::mem::MemDataStore::new); +crate::pinstore_interface_tests!(common_tests, crate::repo::mem::MemDataStore::new); #[cfg(test)] mod tests {