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
pub mod event; #[cfg(test)] mod test { use super::event; #[test] fn test_simple_event() { let mut test_event = event::Event::new(); test_event.add_field( String::from("message"), String::from("this is the error message"), ); let expected_output = format!( "{{\"attributes\":{{\"message\":\"this is the error message\"}},\"created\":{},\"level\":\"INFO\",\"severity\":\"INFO\"}}", serde_json::to_string(&test_event.created).unwrap() ); assert_eq!(&test_event.to_string(), &expected_output); } #[test] fn test_event_parse_from_string() { let test_event: event::Event = "some event".parse().unwrap(); println!("{}", test_event); } #[test] fn test_make_error() { let test_event: event::Event = "something bad happened".parse::<event::Event>().unwrap().error(); assert_eq!(test_event.to_string().contains("ERROR"), true); } }