From 703e6e60dc562199b80fd85c4cc6173ba71ad265 Mon Sep 17 00:00:00 2001 From: KeisukeYamashita <19yamashita15@gmail.com> Date: Fri, 22 Aug 2025 22:39:00 +0900 Subject: [PATCH] chore(cli): add no value test cases for max length linters Signed-off-by: KeisukeYamashita <19yamashita15@gmail.com> --- cli/src/rule/body_max_length.rs | 19 +++++++++++++++++++ cli/src/rule/scope_max_length.rs | 19 +++++++++++++++++++ cli/src/rule/type_max_length.rs | 19 +++++++++++++++++++ 3 files changed, 57 insertions(+) diff --git a/cli/src/rule/body_max_length.rs b/cli/src/rule/body_max_length.rs index ea8b869..0ee7992 100644 --- a/cli/src/rule/body_max_length.rs +++ b/cli/src/rule/body_max_length.rs @@ -84,6 +84,25 @@ Hey!" assert!(rule.validate(&message).is_none()); } + #[test] + fn test_no_body() { + let rule = BodyMaxLength { + length: usize::MAX, // Long length for testing + ..Default::default() + }; + let message = Message { + body: None, + description: Some("broadcast $destroy event on scope destruction".to_string()), + footers: None, + r#type: Some("feat".to_string()), + raw: "feat(scope): broadcast $destroy event on scope destruction".to_string(), + scope: Some("scope".to_string()), + subject: Some("feat(scope): broadcast $destroy event on scope destruction".to_string()), + }; + + assert!(rule.validate(&message).is_none()); + } + #[test] fn test_short_body() { let rule = BodyMaxLength { diff --git a/cli/src/rule/scope_max_length.rs b/cli/src/rule/scope_max_length.rs index f33da11..b4eec49 100644 --- a/cli/src/rule/scope_max_length.rs +++ b/cli/src/rule/scope_max_length.rs @@ -81,6 +81,25 @@ mod tests { assert!(rule.validate(&message).is_none()); } + #[test] + fn test_no_scope() { + let rule = ScopeMaxLength { + length: usize::MAX, // Long length for testing + ..Default::default() + }; + let message = Message { + body: None, + description: Some("desc".to_string()), + footers: None, + r#type: Some("feat".to_string()), + raw: "feat(scope): desc".to_string(), + scope: None, + subject: Some("feat(scope): desc".to_string()), + }; + + assert!(rule.validate(&message).is_none()); + } + #[test] fn test_short_scope() { let rule = ScopeMaxLength { diff --git a/cli/src/rule/type_max_length.rs b/cli/src/rule/type_max_length.rs index 1df8dbb..58c00bc 100644 --- a/cli/src/rule/type_max_length.rs +++ b/cli/src/rule/type_max_length.rs @@ -81,6 +81,25 @@ mod tests { assert!(rule.validate(&message).is_none()); } + #[test] + fn test_no_type() { + let rule = TypeMaxLength { + length: usize::MAX, // Long length for testing + ..Default::default() + }; + let message = Message { + body: None, + description: Some("broadcast $destroy event on scope destruction".to_string()), + footers: None, + r#type: None, + raw: "feat(scope): broadcast $destroy event on scope destruction".to_string(), + scope: Some("scope".to_string()), + subject: Some("feat(scope): broadcast $destroy event on scope destruction".to_string()), + }; + + assert!(rule.validate(&message).is_none()); + } + #[test] fn test_short_type() { let rule = TypeMaxLength {