core/protocol: test de/serialization of all protocol messages
Build and test / check-license (push) Successful in 48s
Build and test / check (push) Successful in 1m44s
Build and test / test (push) Failing after 3m6s
Build and test / build (push) Successful in 3m22s
Build and test / docs (push) Successful in 6m26s

This commit is contained in:
2026-04-28 07:27:55 +09:00
parent b12acbf3b4
commit a737c6cb50
16 changed files with 536 additions and 1 deletions
+30
View File
@@ -94,3 +94,33 @@ impl LockUserError {
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_serialize_deserialize_request() {
let request: LockUsersRequest = vec!["test_user1".into(), "test_user2".into()];
let json = serde_json::to_string_pretty(&request).unwrap();
println!("Serialized request:\n{}", json);
let deserialized: LockUsersRequest = serde_json::from_str(&json).unwrap();
assert_eq!(request, deserialized);
}
#[test]
fn test_serialize_deserialize_response() {
let response_ok: LockUsersResponse = BTreeMap::from([
("test_user1".into(), Ok(())),
("test_user2".into(), Err(LockUserError::UserDoesNotExist)),
]);
let json = serde_json::to_string_pretty(&response_ok).unwrap();
println!("Serialized response:\n{}", json);
let deserialized: LockUsersResponse = serde_json::from_str(&json).unwrap();
assert_eq!(response_ok, deserialized);
}
}