diff --git a/src/plugins/str.rs b/src/plugins/str.rs index 7e8ba6101e..7053bd5e1d 100644 --- a/src/plugins/str.rs +++ b/src/plugins/str.rs @@ -32,7 +32,7 @@ impl Str { Some(Action::ToInteger) => match input.trim().parse::() { Ok(v) => Value::int(v), Err(_) => Value::string(input), - } + }, None => Value::string(input.to_string()), } } @@ -290,6 +290,22 @@ mod tests { assert_eq!(plugin.field, Some("package.description".to_string())); } + #[test] + fn str_plugin_accepts_only_one_action() { + let mut plugin = Str::new(); + + assert!(plugin + .begin_filter( + CallStub::new() + .with_long_flag("upcase") + .with_long_flag("downcase") + .with_long_flag("to-int") + .create(), + ) + .is_err()); + assert_eq!(plugin.error, Some("can only apply one".to_string())); + } + #[test] fn str_downcases() { let mut strutils = Str::new();