1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
extern crate chrono; mod file; mod learned; pub use learned::Learned; pub use file::write_til_file as run; #[cfg(test)] mod tests { use super::*; #[test] fn should_collapse_input_to_string() { let input = vec!["/some/path", "how", "to", "write", "tests", "in", "rust"].into_iter() .map(|i| String::from(i)) .collect(); let result = Learned::new(input).expect("Could not make config from input"); assert_eq!("how to write tests in rust", result.description); } #[test] #[should_panic] fn should_panic_given_not_enough_inputs() { let input = vec!["/some/path".to_string()]; Learned::new(input).expect("Could not make config from input"); } #[test] fn should_format_date() { let dt = Local.ymd(2014, 11, 28); assert_eq!(format_date(dt), "2014-11-28"); } }