diff options
author | Vincent Breitmoser <look@my.amazin.horse> | 2019-01-19 13:51:50 +0100 |
---|---|---|
committer | Vincent Breitmoser <look@my.amazin.horse> | 2019-01-19 13:51:50 +0100 |
commit | 2733f73a485300fc284f2d428b2b31b1f09199fb (patch) | |
tree | 6f90783a9305930495baf6aa81eeeb384f3dad7e /src/config.rs | |
parent | 0fae720eea9c3242bb23ce224d664968239c7ab0 (diff) |
config: more testing
Diffstat (limited to 'src/config.rs')
-rw-r--r-- | src/config.rs | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/config.rs b/src/config.rs index 54941e9..184e7df 100644 --- a/src/config.rs +++ b/src/config.rs @@ -3,7 +3,6 @@ use toml; use yansi::{self,Style,Color}; use defaults; -use icalwrap::IcalVCalendar; use utils::fileutil as utils; #[derive(Deserialize,Debug,PartialEq)] @@ -26,8 +25,7 @@ pub struct CalendarConfig { } impl Config { - pub fn get_config_for_calendar(&self, event: &IcalVCalendar) -> Option<&CalendarConfig> { - let calendar_name = &event.get_calendar_name()?; + pub fn get_config_for_calendar(&self, calendar_name: &str) -> Option<&CalendarConfig> { self.calendars.get(calendar_name) } @@ -87,6 +85,7 @@ mod tests { let _testdir = testutils::prepare_testdir("testdir_config"); let config = Config::read_config(); + let cal_config = config.get_config_for_calendar("sample").unwrap(); let expected = Config { calendars: hashmap!{"sample".to_string() => CalendarConfig { color: Some(81) }}, @@ -95,6 +94,16 @@ mod tests { print_empty_days: false } }; + assert_eq!(expected, config); + assert_eq!(expected.calendars.get("sample").unwrap(), cal_config); + } + + #[test] + fn test_get_style_for_calendar() { + let config = CalendarConfig { color: Some(81) }; + let style = config.get_style_for_calendar(); + + assert_eq!(Color::Fixed(81).style(), style); } } |