File tree 1 file changed +29
-1
lines changed
rocketmq-common/src/common/attribute
1 file changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ impl fmt::Display for CleanupPolicy {
34
34
}
35
35
}
36
36
37
- #[ derive( Debug ) ]
37
+ #[ derive( Debug , PartialEq ) ]
38
38
pub struct ParseCleanupPolicyError ;
39
39
40
40
impl fmt:: Display for ParseCleanupPolicyError {
@@ -54,3 +54,31 @@ impl FromStr for CleanupPolicy {
54
54
}
55
55
}
56
56
}
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
+ }
You can’t perform that action at this time.
0 commit comments