reorder, add test

This commit is contained in:
Felix Ableitner 2024-09-19 14:46:31 +02:00
parent 6c6f7c6dff
commit f43996880e

View file

@ -40,12 +40,19 @@ pub fn application_question_check(
} }
} }
fn not_zero(val: Option<i32>) -> Option<i32> {
match val {
Some(0) => None,
v => v,
}
}
#[cfg(test)] #[cfg(test)]
#[allow(clippy::unwrap_used)] #[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)] #[allow(clippy::indexing_slicing)]
mod tests { 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}; use lemmy_db_schema::{ListingType, RegistrationMode};
#[test] #[test]
@ -93,11 +100,11 @@ mod tests {
RegistrationMode::RequireApplication RegistrationMode::RequireApplication
); );
} }
}
fn not_zero(val: Option<i32>) -> Option<i32> { #[test]
match val { fn test_not_zero() {
Some(0) => None, assert_eq!(None, not_zero(None));
v => v, assert_eq!(None, not_zero(Some(0)));
assert_eq!(Some(5), not_zero(Some(5)));
} }
} }