Skip to content

Commit 9c5c20f

Browse files
authored
[Rust] Fixed missing assert! statements in unit tests (#597)
Several tests in `topic_processor.rs` were missing `assert!` statements around a `match!` condition
1 parent 31f9735 commit 9c5c20f

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

rust/azure_iot_operations_protocol/src/common/topic_processor.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ mod tests {
465465
#[test_case("test/{testToken1}}"; "curly brace end")]
466466
fn test_topic_pattern_new_pattern_invalid(pattern: &str) {
467467
let err = TopicPattern::new(pattern, None, None, &create_topic_tokens()).unwrap_err();
468-
matches!(err.kind(), TopicPatternErrorKind::InvalidPattern(p) if p == pattern);
468+
assert!(matches!(err.kind(), TopicPatternErrorKind::InvalidPattern(p) if p == pattern));
469469
}
470470

471471
#[test_case("validNamespace"; "single level")]
@@ -491,7 +491,9 @@ mod tests {
491491

492492
let err = TopicPattern::new(pattern, None, Some(topic_namespace), &create_topic_tokens())
493493
.unwrap_err();
494-
matches!(err.kind(), TopicPatternErrorKind::InvalidNamespace(n) if n == topic_namespace);
494+
assert!(
495+
matches!(err.kind(), TopicPatternErrorKind::InvalidNamespace(n) if n == topic_namespace)
496+
);
495497
}
496498

497499
#[test_case("test/{{testToken1}"; "open brace")]
@@ -501,7 +503,7 @@ mod tests {
501503
#[test_case("test/{test\u{0000}Token}"; "non-ASCII")]
502504
fn test_topic_pattern_new_pattern_invalid_token(pattern: &str) {
503505
let err = TopicPattern::new(pattern, None, None, &HashMap::new()).unwrap_err();
504-
matches!(err.kind(), TopicPatternErrorKind::InvalidPattern(p) if p == pattern);
506+
assert!(matches!(err.kind(), TopicPatternErrorKind::InvalidPattern(p) if p == pattern));
505507
}
506508

507509
#[test_case("invalid replacement"; "replacement contains space")]
@@ -525,7 +527,9 @@ mod tests {
525527
&HashMap::from([("testToken".to_string(), replacement.to_string())]),
526528
)
527529
.unwrap_err();
528-
matches!(err.kind(), TopicPatternErrorKind::InvalidTokenReplacement(t, r) if t == "testToken" && r == replacement);
530+
assert!(
531+
matches!(err.kind(), TopicPatternErrorKind::InvalidTokenReplacement(t, r) if t == "testToken" && r == replacement)
532+
);
529533
}
530534

531535
#[test_case("test", "test"; "no token")]
@@ -552,7 +556,9 @@ mod tests {
552556
fn test_topic_pattern_new_pattern_invalid_share_name(share_name: &str) {
553557
let err = TopicPattern::new("test", Some(share_name.to_string()), None, &HashMap::new())
554558
.unwrap_err();
555-
matches!(err.kind(), TopicPatternErrorKind::InvalidShareName(s) if s == share_name);
559+
assert!(
560+
matches!(err.kind(), TopicPatternErrorKind::InvalidShareName(s) if s == share_name)
561+
);
556562
}
557563

558564
#[test]
@@ -614,7 +620,9 @@ mod tests {
614620
let pattern = TopicPattern::new(pattern, None, None, &HashMap::new()).unwrap();
615621

616622
let err = pattern.as_publish_topic(tokens).unwrap_err();
617-
matches!(err.kind(), TopicPatternErrorKind::InvalidTokenReplacement(t, r) if t == expected_token && r == expected_replacement);
623+
assert!(
624+
matches!(err.kind(), TopicPatternErrorKind::InvalidTokenReplacement(t, r) if t == expected_token && r == expected_replacement)
625+
);
618626
}
619627

620628
#[test_case("test", "test", &HashMap::new(); "no token")]

0 commit comments

Comments
 (0)