Skip to content

Commit fbdb763

Browse files
Support more string options in From<&str> for QueueType
1 parent 13dc846 commit fbdb763

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/commons.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ pub enum QueueType {
351351

352352
impl From<&str> for QueueType {
353353
fn from(value: &str) -> Self {
354-
match value {
354+
match value.to_ascii_lowercase().as_str() {
355355
"classic" => QueueType::Classic,
356356
"quorum" => QueueType::Quorum,
357357
"stream" => QueueType::Stream,
@@ -363,7 +363,7 @@ impl From<&str> for QueueType {
363363

364364
impl From<String> for QueueType {
365365
fn from(value: String) -> Self {
366-
match value.as_str() {
366+
match value.to_ascii_lowercase().as_str() {
367367
"classic" => QueueType::Classic,
368368
"quorum" => QueueType::Quorum,
369369
"stream" => QueueType::Stream,

tests/unit_queue_tests.rs

+15
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,21 @@ use rabbitmq_http_client::responses::{
1919
};
2020
use serde_json::{json, Map};
2121

22+
#[test]
23+
fn test_unit_queue_type_from_str() {
24+
assert_eq!(QueueType::Classic, QueueType::from("classic"));
25+
assert_eq!(QueueType::Classic, QueueType::from("Classic"));
26+
27+
assert_eq!(QueueType::Quorum, QueueType::from("quorum"));
28+
assert_eq!(QueueType::Quorum, QueueType::from("Quorum"));
29+
30+
assert_eq!(QueueType::Stream, QueueType::from("stream"));
31+
assert_eq!(QueueType::Stream, QueueType::from("Stream"));
32+
33+
assert_eq!(QueueType::Delayed, QueueType::from("delayed"));
34+
assert_eq!(QueueType::Delayed, QueueType::from("Delayed"));
35+
}
36+
2237
#[test]
2338
fn test_unit_policy_target_type_case1() {
2439
let input = r#"{

0 commit comments

Comments
 (0)