mirror of
https://github.com/marcoallegretti/WEFT_OS.git
synced 2026-03-26 17:03:09 +00:00
test(appd): add roundtrip tests for TerminateApp, Error, and AppState IPC variants
This commit is contained in:
parent
60256138a9
commit
dbcc9965e9
1 changed files with 42 additions and 0 deletions
|
|
@ -177,6 +177,48 @@ mod tests {
|
|||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn terminate_app_request_roundtrip() {
|
||||
let req = Request::TerminateApp { session_id: 42 };
|
||||
let bytes = rmp_serde::to_vec(&req).unwrap();
|
||||
let decoded: Request = rmp_serde::from_slice(&bytes).unwrap();
|
||||
assert!(matches!(decoded, Request::TerminateApp { session_id: 42 }));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn error_response_roundtrip() {
|
||||
let resp = Response::Error {
|
||||
code: 1,
|
||||
message: "not found".into(),
|
||||
};
|
||||
let bytes = rmp_serde::to_vec(&resp).unwrap();
|
||||
let decoded: Response = rmp_serde::from_slice(&bytes).unwrap();
|
||||
match decoded {
|
||||
Response::Error { code, message } => {
|
||||
assert_eq!(code, 1);
|
||||
assert_eq!(message, "not found");
|
||||
}
|
||||
_ => panic!("wrong variant"),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn app_state_response_roundtrip() {
|
||||
let resp = Response::AppState {
|
||||
session_id: 5,
|
||||
state: super::AppStateKind::Running,
|
||||
};
|
||||
let bytes = rmp_serde::to_vec(&resp).unwrap();
|
||||
let decoded: Response = rmp_serde::from_slice(&bytes).unwrap();
|
||||
assert!(matches!(
|
||||
decoded,
|
||||
Response::AppState {
|
||||
session_id: 5,
|
||||
state: super::AppStateKind::Running
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn frame_write_read_roundtrip() {
|
||||
let resp = Response::RunningApps { sessions: vec![] };
|
||||
|
|
|
|||
Loading…
Reference in a new issue