From fe8264d867e90931610e1ee282ecef2c5eabc345 Mon Sep 17 00:00:00 2001 From: KeisukeYamashita <19yamashita15@gmail.com> Date: Tue, 13 Feb 2024 19:43:21 +0100 Subject: [PATCH] chore(cli): add test for default option with empty type (#272) Signed-off-by: KeisukeYamashita <19yamashita15@gmail.com> --- src/rule/type.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/rule/type.rs b/src/rule/type.rs index 91cbac2..fef11b5 100644 --- a/src/rule/type.rs +++ b/src/rule/type.rs @@ -124,6 +124,29 @@ mod tests { ); } + #[test] + fn test_no_options_with_empty_type() { + let rule = Type::default(); + + let message = Message { + body: None, + description: None, + footers: None, + r#type: None, + raw: "invalid(scope): broadcast $destroy event on scope destruction".to_string(), + scope: None, + subject: None, + }; + + let violation = rule.validate(&message); + assert!(violation.is_some()); + assert_eq!(violation.clone().unwrap().level, Level::Error); + assert_eq!( + violation.unwrap().message, + "type is not allowed. Only [] are allowed".to_string() + ); + } + #[test] fn test_missing_type() { let rule = Type::default();