[#13] Further overhaul of the project structure for better testing

This commit is contained in:
Jef Roosens 2021-04-08 22:39:04 +02:00
parent e78de73d83
commit 2e73d88ae9
Signed by: Jef Roosens
GPG key ID: B580B976584B5F30
10 changed files with 48 additions and 16 deletions

View file

@ -10,6 +10,7 @@ use std::convert::TryFrom;
/// This class is a simple wrapper around chrono's DateTime. Its sole purpose
/// is to avoid error E0117.
#[derive(Debug, PartialEq)]
pub struct BasicDate(pub DateTime<Tz>);
/// This allows us to use BasicDate as a query parameter in our routes.
@ -54,3 +55,15 @@ impl Serialize for BasicDate {
serializer.serialize_str(&String::from(self))
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_invalid_date() {
let val = "2012-13-12";
let date = BasicDate::try_from(val);
assert_eq!(date, Err(FejError::InvalidArgument));
}
}