Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ symphony = ["communication", "dep:serde", "dep:serde_json", "dep:symphony"]

[dependencies]
async-trait = { version = "0.1" }
bytes = { version = "1.10" }
bytes = { version = "1.11.1" }
mediatype = "0.20"
mockall = { version = "0.13", optional = true }
protobuf = { version = "3.7.2", features = ["with-bytes"] }
Expand All @@ -70,6 +70,7 @@ cucumber = { version = "0.21.1", features = ["output-junit"] }
hex = { version = "0.4.3" }
mockall = { version = "0.13.1" }
test-case = { version = "3.3.1" }
time = { version = "0.3.47" }
tokio = { version = "1.45.1", default-features = false, features = [
"macros",
"rt",
Expand Down
2 changes: 1 addition & 1 deletion src/umessage/umessagebuilder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ impl UMessageBuilder {
/// Sets the message's priority.
///
/// If not set explicitly, the default priority as defined in the
/// [uProtocol specification](https://github.com/eclipse-uprotocol/up-spec/blob/main/basics/qos.adoc)
/// [uProtocol specification](https://github.com/eclipse-uprotocol/up-spec/blob/main/basics/upriority.adoc)
/// is used.
///
/// # Arguments
Expand Down
4 changes: 2 additions & 2 deletions src/umessage/umessagetype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ mod tests {
) {
let result = UMessageType::try_from_cloudevent_type(cloudevent_type);
assert!(result.is_ok() == expected_message_type.is_some());
if expected_message_type.is_some() {
assert_eq!(result.unwrap(), expected_message_type.unwrap())
if let Some(message_type) = expected_message_type {
assert_eq!(result.unwrap(), message_type)
} else {
assert!(matches!(
result.unwrap_err(),
Expand Down
80 changes: 80 additions & 0 deletions src/uri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,27 @@ impl Hash for UUri {

impl Eq for UUri {}

impl PartialEq<str> for UUri {
fn eq(&self, other: &str) -> bool {
match UUri::from_str(other) {
Ok(other_uri) => self.eq(&other_uri),
Err(_) => false,
}
}
}

impl PartialEq<&str> for UUri {
fn eq(&self, other: &&str) -> bool {
self.eq(*other)
}
}

impl PartialEq<String> for UUri {
fn eq(&self, other: &String) -> bool {
self.eq(other.as_str())
}
}

impl UUri {
/// Serializes this UUri to a URI string.
///
Expand Down Expand Up @@ -990,6 +1011,65 @@ mod tests {
use super::*;
use test_case::test_case;

#[test_case(UUri {
authority_name: "vin".into(),
ue_id: 0x0000_8000,
ue_version_major: 0x01,
resource_id: 0x0002,
..Default::default()
},
"//vin/8000/1/2" => true;
"succeeds for full URI with authority")]
#[test_case(UUri {
authority_name: "".into(),
ue_id: 0x0000_8000,
ue_version_major: 0x01,
resource_id: 0x0002,
..Default::default()
},
"up:/8000/1/2" => true;
"succeeds for URI without authority")]
#[test_case(UUri {
authority_name: "vin".into(),
ue_id: 0x0000_8000,
ue_version_major: 0x01,
resource_id: 0x0002,
..Default::default()
},
"//other-vin/8000/1/2" => false;
"fails for different authority")]
#[test_case(UUri {
authority_name: "vin".into(),
ue_id: 0x0000_8000,
ue_version_major: 0x01,
resource_id: 0x0002,
..Default::default()
},
"up://vin/18000/1/2" => false;
"fails for different entity ID")]
#[test_case(UUri {
authority_name: "vin".into(),
ue_id: 0x0000_8000,
ue_version_major: 0x01,
resource_id: 0x0002,
..Default::default()
},
"//vin/8000/2/2" => false;
"fails for different version")]
#[test_case(UUri {
authority_name: "vin".into(),
ue_id: 0x0000_8000,
ue_version_major: 0x01,
resource_id: 0x0002,
..Default::default()
},
"up://vin/8000/1/5" => false;
"fails for different resource ID")]
#[allow(clippy::cmp_owned)]
fn test_eq_with_str(uuri: UUri, uri_str: &str) -> bool {
uuri == uri_str && uuri == *uri_str && uuri == String::from(uri_str)
}

// [utest->dsn~uri-authority-name-length~1]
// [utest->dsn~uri-host-only~2]
#[test_case(UUri {
Expand Down