Skip to content

Commit 5542741

Browse files
authored
[ISSUE #535]✅Add test case for CleanupPolicy (#536)
1 parent d726e0e commit 5542741

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

rocketmq-common/src/common/attribute/cleanup_policy.rs

+29-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ impl fmt::Display for CleanupPolicy {
3434
}
3535
}
3636

37-
#[derive(Debug)]
37+
#[derive(Debug, PartialEq)]
3838
pub struct ParseCleanupPolicyError;
3939

4040
impl fmt::Display for ParseCleanupPolicyError {
@@ -54,3 +54,31 @@ impl FromStr for CleanupPolicy {
5454
}
5555
}
5656
}
57+
58+
#[cfg(test)]
59+
mod tests {
60+
use super::*;
61+
62+
#[test]
63+
fn cleanup_policy_display() {
64+
assert_eq!(CleanupPolicy::DELETE.to_string(), "DELETE");
65+
assert_eq!(CleanupPolicy::COMPACTION.to_string(), "COMPACTION");
66+
}
67+
68+
#[test]
69+
fn cleanup_policy_from_str() {
70+
assert_eq!("DELETE".parse(), Ok(CleanupPolicy::DELETE));
71+
assert_eq!("COMPACTION".parse(), Ok(CleanupPolicy::COMPACTION));
72+
}
73+
74+
#[test]
75+
fn cleanup_policy_from_str_case_insensitive() {
76+
assert_eq!("delete".parse(), Ok(CleanupPolicy::DELETE));
77+
assert_eq!("compaction".parse(), Ok(CleanupPolicy::COMPACTION));
78+
}
79+
80+
#[test]
81+
fn cleanup_policy_from_str_invalid() {
82+
assert!("invalid".parse::<CleanupPolicy>().is_err());
83+
}
84+
}

0 commit comments

Comments
 (0)