update wpactrl tests

This commit is contained in:
glyph 2021-12-13 08:19:25 +02:00
parent c3fa188400
commit 46b7c0fc2b
1 changed files with 17 additions and 12 deletions

View File

@ -842,7 +842,7 @@ mod tests {
let mut io = IoHandler::new(); let mut io = IoHandler::new();
io.add_method("rpc_regex_error", |_| { io.add_method("rpc_regex_error", |_| {
let source = regex::Error::Syntax("oh no!".to_string()); let source = regex::Error::Syntax("oh no!".to_string());
Err(Error::from(NetworkError::Regex { source })) Err(Error::from(NetworkError::Regex(source)))
}); });
test_rpc::Rpc::from(io) test_rpc::Rpc::from(io)
}; };
@ -886,7 +886,7 @@ mod tests {
let mut io = IoHandler::new(); let mut io = IoHandler::new();
io.add_method("rpc_wlanstate_error", |_| { io.add_method("rpc_wlanstate_error", |_| {
let source = IoError::new(ErrorKind::PermissionDenied, "oh no!"); let source = IoError::new(ErrorKind::PermissionDenied, "oh no!");
Err(Error::from(NetworkError::WlanState { source })) Err(Error::from(NetworkError::WlanState(source)))
}); });
test_rpc::Rpc::from(io) test_rpc::Rpc::from(io)
}; };
@ -907,7 +907,7 @@ mod tests {
let mut io = IoHandler::new(); let mut io = IoHandler::new();
io.add_method("rpc_wlanoperstate_error", |_| { io.add_method("rpc_wlanoperstate_error", |_| {
let source = IoError::new(ErrorKind::PermissionDenied, "oh no!"); let source = IoError::new(ErrorKind::PermissionDenied, "oh no!");
Err(Error::from(NetworkError::WlanOperstate { source })) Err(Error::from(NetworkError::WlanOperstate(source)))
}); });
test_rpc::Rpc::from(io) test_rpc::Rpc::from(io)
}; };
@ -945,9 +945,13 @@ mod tests {
let rpc = { let rpc = {
let mut io = IoHandler::new(); let mut io = IoHandler::new();
io.add_method("rpc_wpactrlopen_error", |_| { io.add_method("rpc_wpactrlopen_error", |_| {
let fail_err = failure::err_msg("Permission denied (os error 13)").compat(); let permission_error = IoError::new(
let source = Box::new(fail_err); ErrorKind::PermissionDenied,
Err(Error::from(NetworkError::WpaCtrlOpen { source })) "Permission denied (os error 13)",
);
Err(Error::from(NetworkError::WpaCtrl(wpactrl::WpaError::Io(
permission_error,
))))
}); });
test_rpc::Rpc::from(io) test_rpc::Rpc::from(io)
}; };
@ -956,7 +960,7 @@ mod tests {
rpc.request("rpc_wpactrlopen_error", &()), rpc.request("rpc_wpactrlopen_error", &()),
r#"{ r#"{
"code": -32013, "code": -32013,
"message": "Failed to open control interface for wpasupplicant: Permission denied (os error 13)" "message": "WPA control interface failure: Failed to execute the specified command: Permission denied (os error 13)"
}"# }"#
); );
} }
@ -967,9 +971,10 @@ mod tests {
let rpc = { let rpc = {
let mut io = IoHandler::new(); let mut io = IoHandler::new();
io.add_method("rpc_wpactrlrequest_error", |_| { io.add_method("rpc_wpactrlrequest_error", |_| {
let fail_err = failure::err_msg("oh no!").compat(); let conn_refused_error = IoError::new(ErrorKind::ConnectionRefused, "oh no!");
let source = Box::new(fail_err); Err(Error::from(NetworkError::WpaCtrl(wpactrl::WpaError::Io(
Err(Error::from(NetworkError::WpaCtrlRequest { source })) conn_refused_error,
))))
}); });
test_rpc::Rpc::from(io) test_rpc::Rpc::from(io)
}; };
@ -977,8 +982,8 @@ mod tests {
assert_eq!( assert_eq!(
rpc.request("rpc_wpactrlrequest_error", &()), rpc.request("rpc_wpactrlrequest_error", &()),
r#"{ r#"{
"code": -32014, "code": -32013,
"message": "WPA supplicant request failed: oh no!" "message": "WPA control interface failure: Failed to execute the specified command: oh no!"
}"# }"#
); );
} }