Skip to content

Commit

Permalink
Use panic! instead
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaeling committed Oct 22, 2024
1 parent f1b9b71 commit a655241
Showing 1 changed file with 16 additions and 28 deletions.
44 changes: 16 additions & 28 deletions databroker/src/grpc/kuksa_val_v2/val.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1785,7 +1785,6 @@ mod tests {
async fn test_publish_value() {
let broker = DataBroker::default();
let authorized_access = broker.authorized_access(&permissions::ALLOW_ALL);
let f = false;

let entry_id = authorized_access
.add_entry(
Expand Down Expand Up @@ -1832,7 +1831,7 @@ mod tests {
}
Err(status) => {
// Handle the error from the publish_value function
assert!(f, "Publish failed with status: {:?}", status);
panic!("Publish failed with status: {:?}", status);
}
}
}
Expand All @@ -1841,7 +1840,6 @@ mod tests {
async fn test_publish_value_signal_id_not_found() {
let broker = DataBroker::default();
let authorized_access = broker.authorized_access(&permissions::ALLOW_ALL);
let f = false;

let _entry_id = authorized_access
.add_entry(
Expand Down Expand Up @@ -1883,7 +1881,7 @@ mod tests {
match broker.publish_value(publish_value_request).await {
Ok(_) => {
// Handle the successful response
assert!(f, "Should not happen!");
panic!("Should not happen!");
}
Err(status) => {
// Handle the error from the publish_value function
Expand Down Expand Up @@ -1965,7 +1963,6 @@ mod tests {
},
);

let f = false;
match item {
Ok(subscribe_response) => {
// Process the SubscribeResponse
Expand All @@ -1981,24 +1978,21 @@ mod tests {
assert_eq!(entry1.value, entry2.value);
}
(Some(entry1), None) => {
assert!(f, "Key '{}' is only in response: {:?}", key, entry1)
panic!("Key '{}' is only in response: {:?}", key, entry1)
}
(None, Some(entry2)) => {
panic!("Key '{}' is only in expected_response: {:?}", key, entry2)
}
(None, Some(entry2)) => assert!(
f,
"Key '{}' is only in expected_response: {:?}",
key, entry2
),
(None, None) => unreachable!(),
}
}
}
Err(err) => {
assert!(f, "Error {:?}", err)
panic!("Error {:?}", err)
}
}
}

let f = false;
let broker = DataBroker::default();

let authorized_access = broker.authorized_access(&permissions::ALLOW_ALL);
Expand Down Expand Up @@ -2077,8 +2071,7 @@ mod tests {
// And we do not expect more
break;
}
_ => assert!(
f,
_ => panic!(
"You shouldn't land here too many items reported back to the stream."
),
}
Expand All @@ -2087,7 +2080,7 @@ mod tests {
// Make sure stream is not closed in advance
assert_eq!(item_count, 4);
} else {
assert!(f, "Something went wrong while getting the stream.")
panic!("Something went wrong while getting the stream.")
}
}

Expand Down Expand Up @@ -2119,7 +2112,6 @@ mod tests {
},
);

let f = false;
match item {
Ok(subscribe_response) => {
// Process the SubscribeResponse
Expand All @@ -2131,23 +2123,20 @@ mod tests {
assert_eq!(entry1.value, entry2.value);
}
(Some(entry1), None) => {
assert!(f, "Key '{}' is only in response: {:?}", key, entry1)
panic!("Key '{}' is only in response: {:?}", key, entry1)
}
(None, Some(entry2)) => {
panic!("Key '{}' is only in expected_response: {:?}", key, entry2)
}
(None, Some(entry2)) => assert!(
f,
"Key '{}' is only in expected_response: {:?}",
key, entry2
),
(None, None) => unreachable!(),
}
}
}
Err(err) => {
assert!(f, "Error {:?}", err)
panic!("Error {:?}", err)
}
}
}
let f = false;
let broker = DataBroker::default();

let authorized_access = broker.authorized_access(&permissions::ALLOW_ALL);
Expand Down Expand Up @@ -2231,8 +2220,7 @@ mod tests {
// And we do not expect more
break;
}
_ => assert!(
f,
_ => panic!(
"You shouldn't land here too many items reported back to the stream."
),
}
Expand All @@ -2241,7 +2229,7 @@ mod tests {
// Make sure stream is not closed in advance
assert_eq!(item_count, 4);
} else {
assert!(f, "Something went wrong while getting the stream.")
panic!("Something went wrong while getting the stream.")
}
}

Expand Down

0 comments on commit a655241

Please sign in to comment.