diff options
author | Nora <nora.widdecke@tu-bs.de> | 2019-01-11 21:39:59 +0100 |
---|---|---|
committer | Nora <nora.widdecke@tu-bs.de> | 2019-01-11 21:39:59 +0100 |
commit | 0d9092765359689bd5e9923a751276b5f952e910 (patch) | |
tree | c5c3ae52a8416046b542455479579a9aeaddd5cf /src/icalwrap | |
parent | 0a1726df5dd7244999a3d47f956cb4d192283af6 (diff) |
icalwrap: add more tests
Diffstat (limited to 'src/icalwrap')
-rw-r--r-- | src/icalwrap/icalcomponent.rs | 9 | ||||
-rw-r--r-- | src/icalwrap/icalvcalendar.rs | 19 |
2 files changed, 27 insertions, 1 deletions
diff --git a/src/icalwrap/icalcomponent.rs b/src/icalwrap/icalcomponent.rs index f28d21b..a5825f2 100644 --- a/src/icalwrap/icalcomponent.rs +++ b/src/icalwrap/icalcomponent.rs @@ -70,6 +70,15 @@ mod tests { } #[test] + fn get_property_test_cal() { + let cal = IcalVCalendar::from_str(testdata::TEST_EVENT_MULTIDAY, None).unwrap(); + let prop_name = "PRODID"; + let prop_value: String = cal.get_property_by_name(prop_name).unwrap().get_value(); + + assert_eq!("-//ABC Corporation//NONSGML My Product//EN".to_string(), prop_value); + } + + #[test] fn get_property_test_negative() { let cal = IcalVCalendar::from_str(testdata::TEST_EVENT_MULTIDAY, None).unwrap(); let event = cal.get_principal_event(); diff --git a/src/icalwrap/icalvcalendar.rs b/src/icalwrap/icalvcalendar.rs index a8e617f..57403cd 100644 --- a/src/icalwrap/icalvcalendar.rs +++ b/src/icalwrap/icalvcalendar.rs @@ -201,7 +201,7 @@ impl IcalVCalendar { IcalEventIter::from_vcalendar(self) } - pub fn get_first_event(&self) -> IcalVEvent { + fn get_first_event(&self) -> IcalVEvent { let event = unsafe { ical::icalcomponent_get_first_component( self.get_ptr(), @@ -360,6 +360,16 @@ mod tests { } #[test] + fn with_dtstamp_test() { + let mut cal = IcalVCalendar::from_str(testdata::TEST_EVENT_MULTIDAY, None).unwrap(); + cal = cal.with_dtstamp_now(); + let event = cal.get_principal_event(); + let now_dtstamp = event.get_property_by_name("DTSTAMP").unwrap().get_value(); + let now_expected = format!("{}", Utc::now().format("%Y%m%dT%H%M%SZ")); + assert_eq!(now_expected, now_dtstamp) + } + + #[test] fn get_khaleesi_line_test() { let path = Some(PathBuf::from("test/path")); let cal = IcalVCalendar::from_str(testdata::TEST_EVENT_MULTIDAY_ALLDAY, path).unwrap(); @@ -368,6 +378,13 @@ mod tests { } #[test] + fn get_calendar_name_test() { + let path = Some(PathBuf::from("calname/event")); + let cal = IcalVCalendar::from_str(testdata::TEST_EVENT_MULTIDAY_ALLDAY, path).unwrap(); + assert_eq!("calname".to_string(), cal.get_calendar_name().unwrap()) + } + + #[test] fn test_get_all_properties_cal() { let cal = IcalVCalendar::from_str(testdata::TEST_EVENT_MULTIDAY, None).unwrap(); |