From f43996880ef97ee07cf908bd1fff054c3f347fd5 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Thu, 19 Sep 2024 14:46:31 +0200 Subject: [PATCH] reorder, add test --- crates/api_crud/src/site/mod.rs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/crates/api_crud/src/site/mod.rs b/crates/api_crud/src/site/mod.rs index 87fb1dc1a..462d2f072 100644 --- a/crates/api_crud/src/site/mod.rs +++ b/crates/api_crud/src/site/mod.rs @@ -40,12 +40,19 @@ pub fn application_question_check( } } +fn not_zero(val: Option) -> Option { + match val { + Some(0) => None, + v => v, + } +} + #[cfg(test)] #[allow(clippy::unwrap_used)] #[allow(clippy::indexing_slicing)] mod tests { - use crate::site::{application_question_check, site_default_post_listing_type_check}; + use crate::site::{application_question_check, not_zero, site_default_post_listing_type_check}; use lemmy_db_schema::{ListingType, RegistrationMode}; #[test] @@ -93,11 +100,11 @@ mod tests { RegistrationMode::RequireApplication ); } -} -fn not_zero(val: Option) -> Option { - match val { - Some(0) => None, - v => v, + #[test] + fn test_not_zero() { + assert_eq!(None, not_zero(None)); + assert_eq!(None, not_zero(Some(0))); + assert_eq!(Some(5), not_zero(Some(5))); } }