Skip to content

Commit

Permalink
RpcMessage: add tests for AccessLevel
Browse files Browse the repository at this point in the history
(#14)
  • Loading branch information
j4r0u53k committed Mar 14, 2024
1 parent b1f9c53 commit 50ab39a
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/rpcmessage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,9 @@ impl fmt::Debug for RpcMessage {
mod test {
use crate::RpcValue;
use crate::RpcMessage;
use crate::metamethod::AccessLevel;
use crate::rpcmessage::RpcMessageMetaTags;
use crate::rpcmessage::Tag;

#[test]
fn rpc_request() {
Expand Down Expand Up @@ -467,4 +469,24 @@ mod test {
//let cpon = rq.as_rpcvalue().to_cpon();
//assert_eq!(cpon, format!("<1:1,8:{},10:\"foo\">i{{1:123}}", id + 1));
}

#[test]
fn rpc_msg_access_level_none() {
let rq = RpcMessage::new_request("foo/bar", "baz", None);
assert_eq!(rq.access_level(), None);
}

#[test]
fn rpc_msg_access_level_some() {
let mut rq = RpcMessage::new_request("foo/bar", "baz", None);
rq.set_access_level(AccessLevel::Read);
assert_eq!(rq.access_level(), Some(AccessLevel::Read));
}

#[test]
fn rpc_msg_access_level_compat() {
let mut rq = RpcMessage::new_request("foo/bar", "baz", None);
rq.set_tag(Tag::Access as i32, Some(RpcValue::from("srv")));
assert_eq!(rq.access_level(), Some(AccessLevel::Service));
}
}

0 comments on commit 50ab39a

Please sign in to comment.