From 832c329363dc6c0c7424ad69e8156234dfa07100 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20N=2E=20Robalino?= Date: Tue, 30 Jul 2019 12:17:33 -0500 Subject: [PATCH] Check plugin str flags are wired properly when configuring. --- src/plugins/str.rs | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/plugins/str.rs b/src/plugins/str.rs index f5dec64ca8..86a66fa04a 100644 --- a/src/plugins/str.rs +++ b/src/plugins/str.rs @@ -23,17 +23,14 @@ impl Str { } } + fn actions(&self) -> Vec { + vec![self.downcase, self.upcase, self.int] + } + fn actions_desired(&self) -> u8 { - [self.downcase, self.upcase, self.int].iter().fold( - 0, - |acc, &field| { - if field { - acc + 1 - } else { - acc - } - }, - ) + self.actions() + .iter() + .fold(0, |acc, &field| if field { acc + 1 } else { acc }) } fn is_valid(&self) -> bool { @@ -267,6 +264,17 @@ mod tests { record.into_spanned_value() } + #[test] + fn str_plugin_configuration_flags_wired() { + let mut strutils = Str::new(); + + let config = strutils.config().unwrap(); + + for action_flag in &["downcase", "upcase", "to-int"] { + assert!(config.named.get(*action_flag).is_some()); + } + } + #[test] fn str_accepts_downcase() { let mut strutils = Str::new();