continued reply handler test
All checks were successful
Rust/sat-rs/pipeline/pr-main This commit looks good

This commit is contained in:
Robin Müller 2024-03-06 16:09:12 +01:00
parent 0fa1503a88
commit c832e71bb0
Signed by: muellerr
GPG Key ID: A649FB78196E3849
2 changed files with 51 additions and 0 deletions

View File

@ -398,6 +398,7 @@ mod tests {
TestConverter, TestRouter, TestRoutingErrorHandler, APP_DATA_TOO_SHORT, TEST_APID,
},
verification::{
self,
tests::{SharedVerificationMap, TestVerificationReporter},
FailParams, RequestId, VerificationReportingProvider,
},
@ -638,11 +639,28 @@ mod tests {
let token = test_verif_reporter
.start_success(token, &[])
.expect("start success failure");
let verif_info = test_verif_reporter
.verification_info(&verification::RequestId::from(request_id))
.expect("no verification info found");
assert!(verif_info.started.expect("not started"));
assert!(verif_info.accepted.expect("not accepted"));
reply_handler.add_routed_request(
request_id.into(),
action_id,
token,
Duration::from_millis(1),
);
let action_reply = ActionReplyPusWithIds {
request_id,
action_id,
reply: ActionReplyPus::Completed,
};
reply_handler
.handle_action_reply(action_reply, &[])
.expect("reply handling failure");
let verif_info = test_verif_reporter
.verification_info(&verification::RequestId::from(request_id))
.expect("no verification info found");
assert!(verif_info.completed.expect("not started"));
}
}

View File

@ -1458,6 +1458,7 @@ pub mod tests {
#[allow(dead_code)]
fn is_sync<T: Sync>(_: &T) {}
#[derive(Clone)]
pub struct VerificationStatus {
pub accepted: Option<bool>,
pub started: Option<bool>,
@ -1649,6 +1650,38 @@ pub mod tests {
}
}
impl TestVerificationReporter {
pub fn verification_info(&self, req_id: &RequestId) -> Option<VerificationStatus> {
let verif_map = self.verification_map.lock().unwrap();
let value = verif_map.borrow().get(req_id).cloned();
value
}
pub fn check_accepted(&self, req_id: &RequestId) -> bool {
let verif_map = self.verification_map.lock().unwrap();
if let Some(entry) = verif_map.borrow().get(req_id) {
return entry.accepted.unwrap_or(false);
}
false
}
pub fn check_started(&self, req_id: &RequestId) -> bool {
let verif_map = self.verification_map.lock().unwrap();
if let Some(entry) = verif_map.borrow().get(req_id) {
return entry.started.unwrap_or(false);
}
false
}
pub fn check_completed(&self, req_id: &RequestId) -> bool {
let verif_map = self.verification_map.lock().unwrap();
if let Some(entry) = verif_map.borrow().get(req_id) {
return entry.completed.unwrap_or(false);
}
false
}
}
const TEST_APID: u16 = 0x02;
const EMPTY_STAMP: [u8; 7] = [0; 7];